mirror of
https://github.com/clap-rs/clap
synced 2024-11-12 23:57:10 +00:00
Merge #2010
2010: feat(macros): Add `@global $setting` to set global settings r=pksunkara a=nickelc Co-authored-by: Constantin Nickel <constantin.nickel@gmail.com>
This commit is contained in:
commit
48d308a8ab
2 changed files with 9 additions and 0 deletions
|
@ -312,6 +312,13 @@ macro_rules! clap_app {
|
|||
$($tt)*
|
||||
}
|
||||
};
|
||||
// Global Settings
|
||||
(@app ($builder:expr) (@global_setting $setting:ident) $($tt:tt)*) => {
|
||||
$crate::clap_app!{ @app
|
||||
($builder.global_setting($crate::AppSettings::$setting))
|
||||
$($tt)*
|
||||
}
|
||||
};
|
||||
// Settings
|
||||
(@app ($builder:expr) (@setting $setting:ident) $($tt:tt)*) => {
|
||||
$crate::clap_app!{ @app
|
||||
|
|
2
tests/macros.rs
Executable file → Normal file
2
tests/macros.rs
Executable file → Normal file
|
@ -28,6 +28,8 @@ fn basic() {
|
|||
(version: "0.1")
|
||||
(about: "tests clap library")
|
||||
(author: "Kevin K. <kbknapp@gmail.com>")
|
||||
(@global_setting ColorNever)
|
||||
(@setting VersionlessSubcommands)
|
||||
(@arg opt: -o --option +takes_value ... "tests options")
|
||||
(@arg positional: index(1) "tests positionals")
|
||||
(@arg flag: -f --flag ... +global "tests flags")
|
||||
|
|
Loading…
Reference in a new issue