Skip to content

Commit 2c136b8

Browse files
authored
Merge pull request #70 from coezbek/compact-help-flag
Override the help flag --help and -h to both show HelpShort
2 parents f0be922 + 635ed1b commit 2c136b8

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

crates/rv/src/main.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use anstream::stream::IsTerminal;
22
use camino::{FromPathBufError, Utf8PathBuf};
33
use clap::builder::Styles;
44
use clap::builder::styling::AnsiColor;
5-
use clap::{Parser, Subcommand};
5+
use clap::{ArgAction, Parser, Subcommand};
66
use config::Config;
77
use miette::Report;
88
use rv_cache::CacheArgs;
@@ -39,6 +39,7 @@ const STYLES: Styles = Styles::styled()
3939
#[command(name = "rv")]
4040
#[command(styles=STYLES)]
4141
#[command(version)]
42+
#[command(disable_help_flag = true)]
4243
struct Cli {
4344
/// Ruby directories to search for installations
4445
#[arg(long = "ruby-dir")]
@@ -54,6 +55,10 @@ struct Cli {
5455
#[command(flatten)]
5556
verbose: clap_verbosity_flag::Verbosity<clap_verbosity_flag::InfoLevel>,
5657

58+
// Override the help flag --help and -h to both show HelpShort
59+
#[arg(short = 'h', long = "help", action = ArgAction::HelpShort, global = true)]
60+
_help: Option<bool>,
61+
5762
#[arg(long, env = "RV_COLOR")]
5863
color: Option<ColorMode>,
5964

0 commit comments

Comments
 (0)