diff --git a/ckb-bin/src/helper.rs b/ckb-bin/src/helper.rs index 12b234415fa..f704d351afa 100644 --- a/ckb-bin/src/helper.rs +++ b/ckb-bin/src/helper.rs @@ -1,4 +1,4 @@ -use ckb_logger::{debug, info}; +use ckb_logger::debug; use std::io::{stdin, stdout, Write}; diff --git a/ckb-bin/src/lib.rs b/ckb-bin/src/lib.rs index 3c5c82cdda1..f3edb00e884 100644 --- a/ckb-bin/src/lib.rs +++ b/ckb-bin/src/lib.rs @@ -14,6 +14,8 @@ use colored::Colorize; use daemonize::Daemonize; use helper::raise_fd_limit; use setup_guard::SetupGuard; + +#[cfg(not(target_os = "windows"))] use subcommand::check_process; #[cfg(feature = "with_sentry")] @@ -127,6 +129,7 @@ fn run_app_inner( cli::CMD_STATS => subcommand::stats(setup.stats(matches)?, handle.clone()), cli::CMD_RESET_DATA => subcommand::reset_data(setup.reset_data(matches)?), cli::CMD_MIGRATE => subcommand::migrate(setup.migrate(matches)?), + #[cfg(not(target_os = "windows"))] cli::CMD_DAEMON => subcommand::daemon(setup.daemon(matches)?), _ => unreachable!(), }; @@ -144,13 +147,10 @@ fn run_app_inner( ret } -#[cfg(target_os = "windows")] -fn run_deamon(_cmd: &str, _matches: &ArgMatches) -> bool { - false -} - -#[cfg(not(target_os = "windows"))] fn run_deamon(cmd: &str, matches: &ArgMatches) -> bool { + #[cfg(target_os = "windows")] + return false; + match cmd { cli::CMD_RUN | cli::CMD_MINER => matches.get_flag(cli::ARG_DAEMON), _ => false, diff --git a/ckb-bin/src/subcommand/mod.rs b/ckb-bin/src/subcommand/mod.rs index a9c6b8e99ac..cc75d07be5d 100644 --- a/ckb-bin/src/subcommand/mod.rs +++ b/ckb-bin/src/subcommand/mod.rs @@ -1,3 +1,4 @@ +#[cfg(not(target_os = "windows"))] mod daemon; mod export; mod import; @@ -11,6 +12,7 @@ mod reset_data; mod run; mod stats; +#[cfg(not(target_os = "windows"))] pub use self::daemon::{check_process, daemon}; pub use self::export::export; pub use self::import::import; diff --git a/util/app-config/src/cli.rs b/util/app-config/src/cli.rs index c74a2304a4e..84670434fd5 100644 --- a/util/app-config/src/cli.rs +++ b/util/app-config/src/cli.rs @@ -124,7 +124,7 @@ const GROUP_BA: &str = "ba"; /// return root clap Command pub fn basic_app() -> Command { - Command::new(BIN_NAME) + let command = Command::new(BIN_NAME) .author("Nervos Core Dev ") .about("Nervos CKB - The Common Knowledge Base") .subcommand_required(true) @@ -150,8 +150,12 @@ pub fn basic_app() -> Command { .subcommand(stats()) .subcommand(reset_data()) .subcommand(peer_id()) - .subcommand(migrate()) - .subcommand(daemon()) + .subcommand(migrate()); + + #[cfg(not(target_os = "windows"))] + let command = command.subcommand(daemon()); + + command } /// Parse the command line arguments by supplying the version information. @@ -398,6 +402,7 @@ fn migrate() -> Command { ) } +#[cfg(not(target_os = "windows"))] fn daemon() -> Command { Command::new(CMD_DAEMON) .about("Runs ckb daemon command")