armi.cli.entryPoint module¶
EntryPoint base classes.
See Entry Points.
-
class
armi.cli.entryPoint.
_EntryPointEnforcer
[source]¶ Bases:
type
Simple metaclass used for the EntryPoint abstract base class to enforce class attributes.
-
class
armi.cli.entryPoint.
EntryPoint
[source]¶ Bases:
object
Generic command line entry point.
A valid subclass must provide at least a
name
class attribute, and may also specify the other class attributes described below.-
name
= None¶ The <command-name> that is used to call the command from the command line
-
description
= None¶ A string summarizing the command’s actions. This is summary that is printed when you run python -m armi –list-commands or python -m armi <command-name> –help. If not provided, the docstring of the decorated class will be used instead. In general, the docstring is probably sufficient but this argument allows you to provide a short description of the command while retaining a long and detailed docstring.
-
settingsArgument
= None¶ One of {‘optional’, ‘required’, None}, or unspecified. Specifies whether a settings file argument is to be added to the command’s argument parser. If settingsArgument == ‘required’, then a settings file is a required positional argument. If settingsArgument == ‘optional’, then it is an optional positional argument. Finally, if settingsArgument is None, then no settings file argument is added.
-
splash
= True¶ Whether running the entry point should produce a splash text upon executing.
Setting this to
False
is useful for utility commands that produce standard output that would be needlessly cluttered by the splash text.
-
mode
= None¶ One of {armi.Mode.BATCH, armi.Mode.INTERACTIVE, armi.Mode.GUI}, optional. Specifies the ARMI mode in which the command is run. Default is armi.Mode.BATCH.
-
static
_initSettings
()[source]¶ Initialize settings for this entry point.
Settings given on command line will update this data structure. Override to provide specific settings in the entry point.
-
addOptions
()[source]¶ Add additional command line options.
Values of options added to
self.parser
will be available onself.args
. Values added withcreateOptionFromSetting
will override the setting values in the settings input file.See also
createOptionFromSetting()
A method often called from here to creat CLI options from application settings.
argparse.ArgumentParser.add_argument()
Often called from here using
self.parser.add_argument
to add custom argparse arguments.
-
invoke
() → Optional[int][source]¶ Body of the entry point.
This is an abstract method, and must must be overridden in sub-classes.
-
createOptionFromSetting
(settingName: str, additionalAlias: str = None, suppressHelp: bool = False)[source]¶ Create a CLI option from an ARMI setting.
This will override whatever is in the settings file.
- Parameters
settingName (str) – the setting name
additionalAlises (str) – additional alias for the command line option, be careful and make sure they are all distinct!
supressHelp (bool) – option to suppress the help message when using the command line
--help
function. This is particularly beneficial when many options are being added as they can clutter the--help
to be almost unusable.
-