armi.cli.entryPoint module
EntryPoint base classes.
See Entry Points.
- class armi.cli.entryPoint.EntryPoint[source]
Bases:
objectGeneric command line entry point.
A valid subclass must provide at least a
nameclass attribute, and may also specify the other class attributes described below.Provides a base class for plugin developers to use in creating application-specific CLIs. Valid subclasses must at least provide a
nameclass attribute.Optional class attributes that a subclass may provide include
description, a string describing the command’s actions,splash, a boolean specifying whether to display a splash screen upon execution, andsettingsArgument. IfsettingsArgumentis specified asrequired, then a settings files is a required positional argument. IfsettingsArgumentis set tooptional, then a settings file is an optional positional argument. If None is specified for thesettingsArgument, then no settings file argument is added.- description: str | None = 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: str | None = 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
Falseis useful for utility commands that produce standard output that would be needlessly cluttered by the splash text.
- mode: int | None = 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.
- addOptions()[source]
Add additional command line options.
Values of options added to
self.parserwill be available onself.args. Values added withcreateOptionFromSettingwill override the setting values in the settings input file.See also
createOptionFromSettingA method often called from here to creat CLI options from application settings.
argparse.ArgumentParser.add_argumentOften called from here using
self.parser.add_argumentto add custom argparse arguments.
- invoke() int | None[source]
Body of the entry point.
This is an abstract method, and must must be overridden in sub-classes.
- Returns:
exitcode – Implementations should return an exit code, or
None, which is interpreted the same as zero (successful completion).- Return type:
int or None
- 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
--helpfunction. This is particularly beneficial when many options are being added as they can clutter the--helpto be almost unusable.