rbtools.commands.base.options¶
Command line option management for commands.
New in version 5.0.
Classes
|
Represents an option for a command. |
|
Represents a named group of options. |
- class rbtools.commands.base.options.Option(*opts: str, **attrs)[source]¶
Bases:
object
Represents an option for a command.
The arguments to the constructor should be treated like those to argparse’s add_argument, with the exception that the keyword argument ‘config_key’ is also valid. If config_key is provided it will be used to retrieve the config value as a default if the option is not specified. This will take precedence over the default argument.
Serves as a wrapper around the ArgumentParser options, allowing us to specify defaults which will be grabbed from the configuration after it is loaded.
New in version 5.0: This is the new location for the old
rbtools.commands.Option
class.- add_to(parent: argparse._ActionsContainer, config: Optional[RBToolsConfig] = None, argv: Optional[list[str]] = None) None [source]¶
Add the option to the parent parser or group.
If the option maps to a configuration key, this will handle figuring out the correct default.
Once we’ve determined the right set of flags, the option will be added to the parser.
- class rbtools.commands.base.options.OptionGroup(name: Optional[str] = None, description: Optional[str] = None, option_list: Optional[list[Option]] = None)[source]¶
Bases:
object
Represents a named group of options.
Each group has a name, an optional description, and a list of options. It serves as a way to organize related options, making it easier for users to scan for the options they want.
This works like argparse’s argument groups, but is designed to work with our special Option class.
New in version 5.0: This is the new location for the old
rbtools.commands.OptionGroup
class.- __init__(name: Optional[str] = None, description: Optional[str] = None, option_list: Optional[list[Option]] = None) None [source]¶
Initialize the option group.
- add_to(parser: argparse.ArgumentParser, config: RBToolsConfig, argv: Optional[list[str]] = None) None [source]¶
Add the group and all its contained options to the parser.
- Parameters:
parser (
argparse.ArgumentParser
) – The command-line parser.config (
rbtools.config.RBToolsConfig
) – The loaded RBTools configuration.argv (
list
, deprecated) – Unused legacy argument.