Skip to content

Commit

Permalink
Use better method to imply clap arguments.
Browse files Browse the repository at this point in the history
As shown in <clap-rs/clap#4713>, instead of
`ArgPredicate::IsPresent` to detect `--basis-current`, it should be
`ArgPredicate::Equals("true".into())`.

This allows arbitrary ordering of clap arguments so that help text can
be ordered as desired.
  • Loading branch information
drmikehenry committed Feb 22, 2023
1 parent aec3b3a commit 86ddc07
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,9 @@ Arguments:
Options:
--basis <BASIS> choose alternate basis sequence number
--basis-current choose basis to be current repository state
--standalone force ibundle to be standalone
--allow-empty allow creation of an empty ibundle
--basis-current choose basis to be current repository state
-q, --quiet run quietly
-h, --help Print help information
-V, --version Print version information
Expand Down
12 changes: 6 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,16 @@ struct CreateArgs {
#[arg(long)]
basis: Option<SeqNum>,

/// choose basis to be current repository state
#[arg(long, conflicts_with("basis"))]
basis_current: bool,

/// force ibundle to be standalone
#[arg(
long,
default_value_if(
"basis_current",
clap::builder::ArgPredicate::IsPresent,
clap::builder::ArgPredicate::Equals("true".into()),
Some("true")
)
)]
Expand All @@ -229,16 +233,12 @@ struct CreateArgs {
long,
default_value_if(
"basis_current",
clap::builder::ArgPredicate::IsPresent,
clap::builder::ArgPredicate::Equals("true".into()),
Some("true")
)
)]
allow_empty: bool,

/// choose basis to be current repository state
#[arg(long, conflicts_with("basis"))]
basis_current: bool,

/// run quietly
#[arg(short, long)]
quiet: bool,
Expand Down

0 comments on commit 86ddc07

Please sign in to comment.