From a9ea38bdc40becf9dadd8f096441211e79eba881 Mon Sep 17 00:00:00 2001 From: Erik Kundt Date: Tue, 28 Jan 2025 12:24:31 +0100 Subject: [PATCH] bin: Complete and beautify help --- bin/commands/help.rs | 48 ++++++++++++++++++++++++++++++++++++++------ bin/main.rs | 3 +-- 2 files changed, 43 insertions(+), 8 deletions(-) diff --git a/bin/commands/help.rs b/bin/commands/help.rs index f48d7d25..baa3eb32 100644 --- a/bin/commands/help.rs +++ b/bin/commands/help.rs @@ -10,7 +10,7 @@ use super::*; pub const HELP: Help = Help { name: "help", - description: "TUI help", + description: "Print help", version: env!("CARGO_PKG_VERSION"), usage: "Usage: rad-tui help [--help]", }; @@ -27,7 +27,11 @@ impl Args for Options { } pub fn run(_options: Options, ctx: impl Context) -> anyhow::Result<()> { - term::print("Usage: rad-tui [--help]"); + println!( + "{} {}", + term::format::secondary("Usage:").bold(), + term::format::tertiary("rad-tui [COMMAND] [OPTIONS]"), + ); if let Err(e) = ctx.profile() { term::blank(); @@ -46,18 +50,50 @@ pub fn run(_options: Options, ctx: impl Context) -> anyhow::Result<()> { term::blank(); } - term::print("Common `rad-tui` commands used in various situations:"); term::blank(); + println!("{}", term::format::secondary("Options:").bold(),); + term::info!( + "\t{} {}", + term::format::tertiary(format!("{:-16}", "--no-forward")), + term::format::default("Don't forward command to `rad` (default: false)") + ); + term::info!( + "\t{} {}", + term::format::tertiary(format!("{:-16}", "--json")), + term::format::default("Print version as JSON") + ); + term::info!( + "\t{} {}", + term::format::tertiary(format!("{:-16}", "--version")), + term::format::default("Print version") + ); + term::info!( + "\t{} {}", + term::format::tertiary(format!("{:-16}", "--help")), + term::format::default("Print command specific help") + ); + term::blank(); + println!("{}", term::format::secondary("Commands:").bold(),); + + term::info!( + "\t{} {}", + term::format::tertiary(format!("{:-16}", "version")), + term::format::default("Print version") + ); for help in COMMANDS { term::info!( "\t{} {}", - term::format::bold(format!("{:-12}", help.name)), - term::format::dim(help.description) + term::format::tertiary(format!("{:-16}", help.name)), + term::format::default(help.description) ); } + term::blank(); - term::print("See `rad-tui --help` to learn about a specific command."); + println!( + "See {} to learn about a specific command.", + term::format::tertiary("`rad-tui --help`") + ); term::blank(); Ok(()) diff --git a/bin/main.rs b/bin/main.rs index c4414223..a12c4192 100644 --- a/bin/main.rs +++ b/bin/main.rs @@ -126,7 +126,6 @@ fn parse_args() -> anyhow::Result { } fn print_help() -> anyhow::Result<()> { - VERSION.write(&mut io::stdout())?; println!("{DESCRIPTION}"); println!(); @@ -205,7 +204,7 @@ mod cli { } pub fn is_help() -> ContainsPredicate { - predicate::str::contains("Terminal interfaces for patches") + predicate::str::contains("Radicle terminal interfaces") } }