diff options
author | Canop <cano.petrole@gmail.com> | 2023-07-16 13:26:42 +0200 |
---|---|---|
committer | Canop <cano.petrole@gmail.com> | 2023-07-16 13:26:42 +0200 |
commit | f3f2d7a14c56c25f8ef6212e49f05b4047c0f7ba (patch) | |
tree | b52ee37f2721b5558b9e4f6511dc7606b83ae552 | |
parent | 180abce49dd55cb101a717732a235ea5cb2b4c2e (diff) |
improve help with clap-help 0.4
-rw-r--r-- | CHANGELOG.md | 3 | ||||
-rw-r--r-- | Cargo.lock | 6 | ||||
-rw-r--r-- | Cargo.toml | 5 | ||||
-rw-r--r-- | src/cli/args.rs | 36 | ||||
-rw-r--r-- | src/cli/mod.rs | 17 |
5 files changed, 43 insertions, 24 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 4741fb6..bd02edf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +### next +- slightly better `--help` + ### v1.24.0 - 2023-07-16 <a name="v1.24.0"></a> - installer for the powershell br script on windows @@ -214,7 +214,7 @@ checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" [[package]] name = "broot" -version = "1.24.0" +version = "1.24.1-dev" dependencies = [ "ahash 0.8.3", "ansi_colours", @@ -348,9 +348,9 @@ dependencies = [ [[package]] name = "clap-help" -version = "0.1.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44ec988f64068922a22fedd28c435c0a5b96024946d93e127bf01f67f16a7761" +checksum = "f4b3eba3ab317a63397bc3fdb01cc06c55be0221e23994d26a41fd9d99facc11" dependencies = [ "clap", "termimad 0.23.1", @@ -1,6 +1,6 @@ [package] name = "broot" -version = "1.24.0" +version = "1.24.1-dev" authors = ["dystroy <denys.seguret@gmail.com>"] repository = "https://github.com/Canop/broot" homepage = "https://dystroy.org/broot" @@ -28,7 +28,7 @@ bet = "1.0.2" char_reader = "0.1" chrono = "0.4" clap = { version = "4.3", features = ["derive", "cargo"] } -clap-help = "0.1.0" +clap-help = "0.3.0" cli-log = "2.0" crokey = "0.4.3" crossbeam = "=0.8" @@ -107,6 +107,7 @@ harness = false [patch.crates-io] # bet = { path = "../bet" } # crokey = { path = "../crokey" } +# clap-help = { path = "../clap-help" } # cli-log = { path = "../cli-log" } # crossterm = { path = "../crossterm-rs/crossterm" } # deser-hjson = { path = "../deser-hjson" } diff --git a/src/cli/args.rs b/src/cli/args.rs index 5fff728..aaa6c6b 100644 --- a/src/cli/args.rs +++ b/src/cli/args.rs @@ -9,9 +9,17 @@ use { /// Launch arguments #[derive(Debug, Parser)] -#[command(author, version, about, disable_help_flag = true)] +#[command(author, about, version, disable_version_flag = true, disable_help_flag = true)] pub struct Args { + /// print help information + #[arg(long)] + pub help: bool, + + /// print the version + #[arg(long)] + pub version: bool, + /// Show the last modified date of files and directories #[arg(short, long)] pub dates: bool, @@ -44,10 +52,6 @@ pub struct Args { /// Only show files having an interesting git status, including hidden ones pub git_status: bool, - /// Print help information - #[arg(long)] - pub help: bool, - #[arg(short='h', long)] /// Show hidden files pub hidden: bool, @@ -121,23 +125,23 @@ pub struct Args { pub no_trim_root: bool, /// Where to write the produced cmd (if any) - #[arg(long)] + #[arg(long, value_name = "path")] pub outcmd: Option<PathBuf>, /// Semicolon separated commands to execute - #[arg(short, long)] + #[arg(short, long, value_name = "commands")] pub cmd: Option<String>, /// Whether to have styles and colors (default is usually OK) - #[arg(long, default_value="auto")] + #[arg(long, default_value="auto", value_name = "color")] pub color: TriBool, /// Semicolon separated paths to specific config files - #[arg(long)] + #[arg(long, value_name = "paths")] pub conf: Option<String>, /// Height (if you don't want to fill the screen or for file export) - #[arg(long)] + #[arg(long, value_name = "height")] pub height: Option<u16>, /// Install or reinstall the br shell function @@ -145,16 +149,16 @@ pub struct Args { pub install: bool, /// Where to write the produced cmd (if any) - #[arg(long)] + #[arg(long, value_name = "state")] pub set_install_state: Option<CliShellInstallState>, /// Print to stdout the br function for a given shell - #[arg(long)] + #[arg(long, value_name = "shell")] pub print_shell_function: Option<String>, /// A socket to listen to for commands #[cfg(unix)] - #[arg(long)] + #[arg(long, value_name = "socket")] pub listen: Option<String>, /// Ask for the current root of the remote broot @@ -163,12 +167,12 @@ pub struct Args { pub get_root: bool, /// Write default conf files in given directory - #[arg(long)] + #[arg(long, value_name = "path")] pub write_default_conf: Option<PathBuf>, - /// A socket that broot sends commands to before quitting + /// A socket to send commands to #[cfg(unix)] - #[arg(long)] + #[arg(long, value_name = "socket")] pub send: Option<String>, /// Root Directory diff --git a/src/cli/mod.rs b/src/cli/mod.rs index b5fd673..8abf805 100644 --- a/src/cli/mod.rs +++ b/src/cli/mod.rs @@ -34,9 +34,14 @@ use { }; static INTRO: &str = " -A tree explorer and a customizable launcher -Complete documentation lives at https://dystroy.org/broot +**broot** lets you explore file hierarchies with a tree-like view, manipulate and preview files, launch actions, and define your own shortcuts. + +**broot** is best launched as `br`: this shell function gives you access to more commands, especially `cd.` The br shell function is interactively installed on first broot launch. + +Flags and options can be classically passed on launch but also written in the configuration file. Each flag has a counter-flag so that you can cancel at command line a flag which has been set in the configuration file. + +Complete documentation and tips at https://dystroy.org/broot "; /// run the application, and maybe return a launchable @@ -49,11 +54,17 @@ pub fn run() -> Result<Option<Launchable>, ProgramError> { if args.help { Printer::new(Args::command()) - .with_introduction(INTRO) + .with("introduction", INTRO) + .without("author") .print_help(); must_quit = true; } + if args.version { + println!("broot {}", env!("CARGO_PKG_VERSION")); + must_quit = true; + } + if let Some(dir) = &args.write_default_conf { write_default_conf_in(dir)?; must_quit = true; |