feat(macros): Add @global_setting $setting to set global settings

This commit is contained in:
Constantin Nickel 2020-07-12 20:07:36 +02:00
parent d8fccdb0ea
commit fbfbf8df99
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")