Skip to content

Commit

Permalink
fix(complete): Return leading dash on short args
Browse files Browse the repository at this point in the history
  • Loading branch information
ModProg authored and epage committed Jul 28, 2023
1 parent 0669994 commit a59c175
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion clap_complete/src/dynamic/completer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,17 @@ fn complete_arg(
}

if arg.is_empty() || arg.is_stdio() || arg.is_short() {
let dash_or_arg = if arg.is_empty() {
"-".into()
} else {
arg.to_value_os().to_string_lossy()
};
// HACK: Assuming knowledge of is_stdio
completions.extend(
crate::generator::utils::shorts_and_visible_aliases(cmd)
.into_iter()
// HACK: Need better `OsStr` manipulation
.map(|f| format!("{}{}", arg.to_value_os().to_string_lossy(), f).into()),
.map(|f| format!("{}{}", dash_or_arg, f).into()),
);
}
}
Expand Down

0 comments on commit a59c175

Please sign in to comment.