Skip to content

Commit

Permalink
safeguard: Use shorter argument value names
Browse files Browse the repository at this point in the history
For whatever reason clap employs some nonsensical heuristic where it
switches to the long help text when options and their arguments exceed a
certain length (or the resulting line reaches the terminal width or
whatever). We can "fix" that with terminal width setting, except that we
are not really interested in overwriting the terminal width, we just
want to disable this stupid heuristic.
In the past we circumvented it by specifying a shorter "name" property,
but of course we forgot about these adjustments once more options were
added. As a result, the long help text was used again with the
--min-gain-percent option.
Now, it turns out that this is not exactly the property we need, because
we can't use the same name multiple times. What we really want is the
"value name".
 So with this change we set this property for the offending arguments.
  • Loading branch information
d-e-s-o committed Feb 21, 2024
1 parent 9e25b68 commit 258e60b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ext/safeguard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ struct Args {
#[clap(long)]
apcacli: Option<OsString>,
/// Set the stop price at this many percentage points gained.
#[clap(short, long, name = "PERCENT")]
#[clap(short, long, value_name = "PERCENT")]
stop_percent: Option<usize>,
/// The minimum value of a position required for stop-loss order
/// creation.
#[clap(short, long)]
#[clap(short, long, value_name = "VALUE")]
min_value: Option<usize>,
/// The minimum gain a position needs to have for it to be considered
/// for stop-loss order creation.
#[clap(short = 'g', long, default_value = "5")]
#[clap(short = 'g', long, value_name = "PERCENT", default_value = "5")]
min_gain_percent: usize,
/// Increase verbosity (can be supplied multiple times).
#[clap(short = 'v', long = "verbose", global = true, action = ArgAction::Count)]
Expand Down

0 comments on commit 258e60b

Please sign in to comment.