mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 22:32:33 +00:00
api(App): adds App::unset_global_setting to be able to unset a globa setting
This commit is contained in:
parent
60c634be51
commit
2264b255d3
2 changed files with 44 additions and 24 deletions
|
@ -491,34 +491,10 @@ impl<'a, 'b> App<'a, 'b> {
|
|||
self
|
||||
}
|
||||
|
||||
/// Enables a single setting that is propagated down through all child [`SubCommand`]s.
|
||||
///
|
||||
/// See [`AppSettings`] for a full list of possibilities and examples.
|
||||
///
|
||||
/// **NOTE**: The setting is *only* propagated *down* and not up through parent commands.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```no_run
|
||||
/// # use clap::{App, Arg, AppSettings};
|
||||
/// App::new("myprog")
|
||||
/// .global_setting(AppSettings::SubcommandRequired)
|
||||
/// # ;
|
||||
/// ```
|
||||
/// [`SubCommand`]: ./struct.SubCommand.html
|
||||
/// [`AppSettings`]: ./enum.AppSettings.html
|
||||
pub fn global_setting(mut self, setting: AppSettings) -> Self {
|
||||
self.settings.set(setting);
|
||||
self.g_settings.set(setting);
|
||||
self
|
||||
}
|
||||
|
||||
/// Disables a single command, or [`SubCommand`], level setting.
|
||||
///
|
||||
/// See [`AppSettings`] for a full list of possibilities and examples.
|
||||
///
|
||||
/// **NOTE:** The setting being unset will be unset from both local and [global] settings
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```no_run
|
||||
|
@ -531,6 +507,48 @@ impl<'a, 'b> App<'a, 'b> {
|
|||
/// [`AppSettings`]: ./enum.AppSettings.html
|
||||
/// [global]: ./struct.App.html#method.global_setting
|
||||
pub fn unset_setting(mut self, setting: AppSettings) -> Self {
|
||||
self.settings.unset(setting);
|
||||
self
|
||||
}
|
||||
|
||||
/// Enables a single setting that is propagated down through all child subcommands.
|
||||
///
|
||||
/// See [`AppSettings`] for a full list of possibilities and examples.
|
||||
///
|
||||
/// **NOTE**: The setting is *only* propagated *down* and not up through parent commands.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```no_run
|
||||
/// # use clap::{App, Arg, AppSettings};
|
||||
/// App::new("myprog")
|
||||
/// .global_setting(AppSettings::SubcommandRequired)
|
||||
/// # ;
|
||||
/// ```
|
||||
/// [`AppSettings`]: ./enum.AppSettings.html
|
||||
pub fn global_setting(mut self, setting: AppSettings) -> Self {
|
||||
self.settings.set(setting);
|
||||
self.g_settings.set(setting);
|
||||
self
|
||||
}
|
||||
|
||||
/// Disables a global setting, and stops propagating down to child subcommands.
|
||||
///
|
||||
/// See [`AppSettings`] for a full list of possibilities and examples.
|
||||
///
|
||||
/// **NOTE:** The setting being unset will be unset from both local and [global] settings
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```no_run
|
||||
/// # use clap::{App, AppSettings};
|
||||
/// App::new("myprog")
|
||||
/// .unset_global_setting(AppSettings::ColorAuto)
|
||||
/// # ;
|
||||
/// ```
|
||||
/// [`AppSettings`]: ./enum.AppSettings.html
|
||||
/// [global]: ./struct.App.html#method.global_setting
|
||||
pub fn unset_global_setting(mut self, setting: AppSettings) -> Self {
|
||||
self.settings.unset(setting);
|
||||
self.g_settings.unset(setting);
|
||||
self
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
* Multiple delima fixed (vals vs occurrences)
|
||||
* Ability to mutate args once they've been added to an `App`
|
||||
* `App::args` and `App::arg` are more generic
|
||||
* Can unset global settings
|
||||
|
||||
# How to Upgrade
|
||||
|
||||
|
@ -61,6 +62,7 @@
|
|||
## App
|
||||
|
||||
* `App::mut_arg`
|
||||
* `App::unset_global_setting`
|
||||
|
||||
## Arg
|
||||
|
||||
|
|
Loading…
Reference in a new issue