mirror of
https://github.com/clap-rs/clap
synced 2024-12-14 14:52:33 +00:00
feat: add rest argument completion
This commit is contained in:
parent
c19fc425d0
commit
c6fe49aba5
2 changed files with 10 additions and 5 deletions
|
@ -17,7 +17,7 @@
|
|||
|
||||
use clap::{
|
||||
builder::{PossibleValue, StyledStr},
|
||||
Arg, Command, Id,
|
||||
Arg, ArgAction, Command, Id,
|
||||
};
|
||||
use clap_complete::Generator;
|
||||
|
||||
|
@ -137,11 +137,16 @@ impl ToString for Argument<'_, '_> {
|
|||
let mut s = String::new();
|
||||
|
||||
if self.is_positional() {
|
||||
// rest arguments
|
||||
if matches!(self.arg.get_action(), ArgAction::Append) {
|
||||
s.push_str(format!(" ...{}", self.get_id()).as_str());
|
||||
} else {
|
||||
s.push_str(format!(" {}", self.get_id()).as_str());
|
||||
|
||||
if !self.is_required_set() {
|
||||
s.push('?');
|
||||
}
|
||||
}
|
||||
|
||||
self.append_type_and_help(&mut s);
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ module completions {
|
|||
# tests other things
|
||||
export extern "my-app some_cmd" [
|
||||
--config: string # the other case to test
|
||||
path?: string
|
||||
...path: string
|
||||
--version(-V) # Print version information
|
||||
]
|
||||
|
||||
|
|
Loading…
Reference in a new issue