-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Positional Args): allows specifying the second to last positiona…
…l argument as multiple(true) Now one can build CLIs that support things like `mv <files>... <target>` There are a few requirements and caveats; * The final positional argument (and all positional arguments prior) *must* be required * Only one positional argument may be `multiple(true)` * Only the second to last, or last positional argument may be `multiple(true)` Closes #725
- Loading branch information
Showing
4 changed files
with
143 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1250,7 +1250,7 @@ impl<'a, 'b> App<'a, 'b> { | |
/// [`AppSettings::NoBinaryName`]: ./enum.AppSettings.html#variant.NoBinaryName | ||
pub fn get_matches_from<I, T>(mut self, itr: I) -> ArgMatches<'a> | ||
where I: IntoIterator<Item = T>, | ||
T: Into<OsString> | ||
T: Into<OsString> + Clone | ||
{ | ||
self.get_matches_from_safe_borrow(itr).unwrap_or_else(|e| { | ||
// Otherwise, write to stderr and exit | ||
|
@@ -1292,7 +1292,7 @@ impl<'a, 'b> App<'a, 'b> { | |
/// [`AppSettings::NoBinaryName`]: ./enum.AppSettings.html#variant.NoBinaryName | ||
pub fn get_matches_from_safe<I, T>(mut self, itr: I) -> ClapResult<ArgMatches<'a>> | ||
where I: IntoIterator<Item = T>, | ||
T: Into<OsString> | ||
T: Into<OsString> + Clone | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
kbknapp
Author
Member
|
||
{ | ||
self.get_matches_from_safe_borrow(itr) | ||
} | ||
|
@@ -1320,7 +1320,7 @@ impl<'a, 'b> App<'a, 'b> { | |
/// [`AppSettings::NoBinaryName`]: ./enum.AppSettings.html#variant.NoBinaryName | ||
pub fn get_matches_from_safe_borrow<I, T>(&mut self, itr: I) -> ClapResult<ArgMatches<'a>> | ||
where I: IntoIterator<Item = T>, | ||
T: Into<OsString> | ||
T: Into<OsString> + Clone | ||
{ | ||
// Verify all positional assertions pass | ||
self.p.verify_positionals(); | ||
|
@@ -1355,7 +1355,7 @@ impl<'a, 'b> App<'a, 'b> { | |
} | ||
|
||
// do the real parsing | ||
if let Err(e) = self.p.get_matches_with(&mut matcher, &mut it) { | ||
if let Err(e) = self.p.get_matches_with(&mut matcher, &mut it.peekable()) { | ||
return Err(e); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FYI, adding Clone here is technically a breaking change (it broke my build). Is there a way to remove this bound without breaking the multiple positional arguments feature?