@@ -435,6 +435,53 @@ impl<'a, 'b> App<'a, 'b> {
435
435
self
436
436
}
437
437
438
+ /// Enables a single setting that is propogated *down* through all child [`SubCommand`]s.
439
+ ///
440
+ /// See [`AppSettings`] for a full list of possibilities and examples.
441
+ ///
442
+ /// **NOTE**: The setting is *only* propogated *down* and not up through parent commands.
443
+ ///
444
+ /// # Examples
445
+ ///
446
+ /// ```no_run
447
+ /// # use clap::{App, Arg, AppSettings};
448
+ /// App::new("myprog")
449
+ /// .global_setting(AppSettings::SubcommandRequired)
450
+ /// # ;
451
+ /// ```
452
+ /// [`SubCommand`]: ./struct.SubCommand.html
453
+ /// [`AppSettings`]: ./enum.AppSettings.html
454
+ pub fn global_setting ( mut self , setting : AppSettings ) -> Self {
455
+ self . p . set ( setting) ;
456
+ self . p . g_settings . push ( setting) ;
457
+ self
458
+ }
459
+
460
+ /// Enables multiple settings which are propogated *down* through all child [`SubCommand`]s.
461
+ ///
462
+ /// See [`AppSettings`] for a full list of possibilities and examples.
463
+ ///
464
+ /// **NOTE**: The setting is *only* propogated *down* and not up through parent commands.
465
+ ///
466
+ /// # Examples
467
+ ///
468
+ /// ```no_run
469
+ /// # use clap::{App, Arg, AppSettings};
470
+ /// App::new("myprog")
471
+ /// .global_settings(&[AppSettings::SubcommandRequired,
472
+ /// AppSettings::ColoredHelp])
473
+ /// # ;
474
+ /// ```
475
+ /// [`SubCommand`]: ./struct.SubCommand.html
476
+ /// [`AppSettings`]: ./enum.AppSettings.html
477
+ pub fn global_settings ( mut self , settings : & [ AppSettings ] ) -> Self {
478
+ for s in settings {
479
+ self . p . set ( * s) ;
480
+ self . p . g_settings . push ( * s)
481
+ }
482
+ self
483
+ }
484
+
438
485
/// Adds an [argument] to the list of valid possibilties.
439
486
///
440
487
/// # Examples
0 commit comments