From 27cccadc1c96e03cffd4a65cde108143f31ab477 Mon Sep 17 00:00:00 2001 From: yukang Date: Thu, 26 Oct 2023 00:20:19 +0800 Subject: [PATCH] wrap help message with max width --- Cargo.lock | 11 +++++++++++ util/app-config/Cargo.toml | 2 +- util/app-config/src/cli.rs | 7 ++++--- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8c411151fe..3a4d777e98 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1644,6 +1644,7 @@ dependencies = [ "anstyle", "clap_lex", "strsim", + "terminal_size", ] [[package]] @@ -4605,6 +4606,16 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "terminal_size" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21bebf2b7c9e0a515f6e0f8c51dc0f8e4696391e6f1ff30379559f8365fb0df7" +dependencies = [ + "rustix", + "windows-sys 0.48.0", +] + [[package]] name = "thiserror" version = "1.0.50" diff --git a/util/app-config/Cargo.toml b/util/app-config/Cargo.toml index ad98178181..fdc97feeb3 100644 --- a/util/app-config/Cargo.toml +++ b/util/app-config/Cargo.toml @@ -9,7 +9,7 @@ homepage = "https://github.com/nervosnetwork/ckb" repository = "https://github.com/nervosnetwork/ckb" [dependencies] -clap = { version = "4", features = ["string"] } +clap = { version = "4", features = ["string", "wrap_help"] } serde = { version = "1.0", features = ["derive"] } serde_plain = "0.3.0" serde_json = "1.0" diff --git a/util/app-config/src/cli.rs b/util/app-config/src/cli.rs index 522d3faee8..2c4044f7f7 100644 --- a/util/app-config/src/cli.rs +++ b/util/app-config/src/cli.rs @@ -122,6 +122,7 @@ pub fn basic_app() -> Command { .about("Nervos CKB - The Common Knowledge Base") .subcommand_required(true) .arg_required_else_help(true) + .term_width(110) .arg( Arg::new(ARG_CONFIG_DIR) .global(true) @@ -186,13 +187,13 @@ fn run() -> Command { .help("This parameter specifies the hash of a block. \ When the height does not reach this block's height, the execution of the script will be disabled, \ that is, skip verifying the script content. \ - \ - It should be noted that when this option is enabled, the header is first synchronized to \ + \n\nIt should be noted that when this option is enabled, the header is first synchronized to \ the highest currently found. During this period, if the assume valid target is found, \ the download of the block starts; If the assume valid target is not found or it's \ timestamp within 24 hours of the current time, the target will automatically become invalid, \ and the download of the block will be started with verify") - ).arg( + ) + .arg( Arg::new(ARG_INDEXER) .long(ARG_INDEXER) .action(clap::ArgAction::SetTrue)