Commit 6ae0960c1dc54a57bf84bf7894b38e898d242019

Authored by Henry Fredrick Schreiner
Committed by Henry Schreiner
1 parent 366716ee

Updating readme

Showing 1 changed file with 13 additions and 1 deletions
README.md
... ... @@ -242,10 +242,22 @@ sub.subcommand = true
242 242 Spaces before and after the name and argument are ignored. Multiple arguments are separated by spaces. One set of quotes will be removed, preserving spaces (the same way the command line works). Boolean options can be `true`, `on`, `1`, `yes`; or `false`, `off`, `0`, `no` (case insensitive). Sections (and `.` separated names) are treated as subcommands (note: this does not mean that subcommand was passed, it just sets the "defaults". To print a configuration file from the passed
243 243 arguments, use `.config_to_str(default_also=false)`, where `default_also` will also show any defaulted arguments.
244 244  
  245 +## Inheriting defaults
  246 +
  247 +Many of the defaults for subcommands and even options are inherited from their creators. The inherited default values for subcommands are `allow_extras`, `prefix_command`, `ignore_case`, `fallthrough`, `group`, and `footer`. The help flag existence, name, and description are inherited, as well.
  248 +
  249 +Options have defaults for `group`, `required`, `take_last`, and `ignore_case`. To set these defaults, you should set the `option_defauts()` object, for example:
  250 +
  251 +```cpp
  252 +app.option_defauts()->required();
  253 +// All future options will be required
  254 +```
  255 +
  256 +The default settings for options are inherited to subcommands, as well.
245 257  
246 258 ## Subclassing
247 259  
248   -The App class was designed allow toolkits to subclass it, to provide default options and setup/teardown code. Subcommands remain an unsubclassed `App`, since those are not expected to need setup and teardown. The default `App` only adds a help flag, `-h,--help`, but provides an option to disable it in the constructor (and in `add_subcommand`), and can removed/replaced using `.set_help_flag(name, help_string)`. You can remove options if you have pointers to them using `.remove_option(opt)`. You can add a `pre_callback` override to customize the after parse
  260 +The App class was designed allow toolkits to subclass it, to provide preset default options (see above) and setup/teardown code. Subcommands remain an unsubclassed `App`, since those are not expected to need setup and teardown. The default `App` only adds a help flag, `-h,--help`, than can removed/replaced using `.set_help_flag(name, help_string)`. You can remove options if you have pointers to them using `.remove_option(opt)`. You can add a `pre_callback` override to customize the after parse
249 261 but before run behavior, while
250 262 still giving the user freedom to `set_callback` on the main app.
251 263  
... ...