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:
bors[bot] 2020-07-14 18:39:26 +00:00 committed by GitHub
commit 48d308a8ab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View file

@ -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
View 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")