From e78621bcde92ae61191f70db55f994f8576de035 Mon Sep 17 00:00:00 2001 From: Eval EXEC Date: Wed, 14 Jun 2023 16:39:32 +0800 Subject: [PATCH] Fix `ckb init -c unsupported_spec` should not create config files --- util/app-config/src/cli.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/util/app-config/src/cli.rs b/util/app-config/src/cli.rs index a63a974b86..522d3faee8 100644 --- a/util/app-config/src/cli.rs +++ b/util/app-config/src/cli.rs @@ -1,6 +1,6 @@ //! CKB command line arguments parser. use ckb_build_info::Version; -use ckb_resource::{DEFAULT_P2P_PORT, DEFAULT_RPC_PORT, DEFAULT_SPEC}; +use ckb_resource::{AVAILABLE_SPECS, DEFAULT_P2P_PORT, DEFAULT_RPC_PORT, DEFAULT_SPEC}; use clap::{Arg, ArgGroup, ArgMatches, Command}; /// binary file name(ckb) @@ -414,6 +414,12 @@ fn init() -> Command { Arg::new(ARG_CHAIN) .short('c') .long(ARG_CHAIN) + .value_parser( + AVAILABLE_SPECS + .iter() + .map(|v| v.to_string()) + .collect::>(), + ) .default_value(DEFAULT_SPEC) .help("Initializes CKB directory for "), )