Skip to content

Commit

Permalink
Correctly allow no-args special support
Browse files Browse the repository at this point in the history
  • Loading branch information
passcod committed Jan 4, 2024
1 parent 881e116 commit 4e40046
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,18 @@ pub fn set_commands(builder: &mut ConfigBuilder, matches: &ArgMatches) {

let subcommand_cargo = {
let (name, args) = matches.subcommand();
if name == "" {
if name.is_empty() {
None
} else if let Some(args) = args {
let args = values_t!(args, "args", String).unwrap_or_else(|e| e.exit()).join(" ");
Some(format!("{name} {args}"))
let mut cargo_cmd = vec![name.to_string()];
cargo_cmd.extend(values_t!(args, "args", String).unwrap_or_else(|e| {
if e.kind == ErrorKind::ArgumentNotFound {
Vec::new()
} else {
e.exit()
}
}));
Some(cargo_cmd.join(" "))
} else {
// shouldn't happen per clap2, but just in case:
Some(name.to_string())
Expand Down

0 comments on commit 4e40046

Please sign in to comment.