mirror of
https://github.com/clap-rs/clap
synced 2024-11-10 14:54:15 +00:00
feat(macros): Add @global_setting $setting
to set global settings
This commit is contained in:
parent
d8fccdb0ea
commit
fbfbf8df99
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