CLI¶
Method
|
Description
|
|---|---|
| cli | Default constructor.
|
| set_category | Sets the current category.
|
| insert_command | Inserts a command.
|
| insert_read_command | Inserts a read command.
|
| insert_write_command | Inserts a write command.
|
| run | Runs the shell.
|
-
template <class... S>
classcli¶ CLI main class.
The stores of a CLI are passed as type arguments to
cli. For example, if the CLI has stores for Graphs and Trees which are handled by classesgraphandtree, respectively, the class instantiation iscli<graph, tree>.Public Functions
-
cli(const std::string &prefix)¶ Default constructor.
Initializes the CLI with a prefix that is used as a command prefix in stand-alone application mode and as a module name when build as Python module.
The constructor will add the default commands to the CLI. If no store type is specified, then no store-related command will be added.
- Parameters
prefix: Either command prefix or module name (depending on build mode)
-
void
set_category(const std::string &_category)¶ Sets the current category.
This category will be used as category for all commands that are added afterwards, until this method is called again with a different argument.
The categories are used in the
helpcommand to organize the commands.The macros :c:macro:
ALICE_COMMANDand :c:macro:ALICE_ADD_COMMANDwill automatically call this method.- Parameters
_category: Category name
Inserts a command.
Inserts a command (as a shared pointer) to the CLI.
The macro :c:macro:
ALICE_ADD_COMMANDwill automatically call this method with a convention that a command with name<name>must be called<name>_command.- Parameters
name: Name of the commandcmd: Shared pointer to a command instance
-
template <typename Tag>
voidinsert_read_command(const std::string &name, const std::string &label)¶ Inserts a read command.
Inserts a read command for a given file tag. The name of the command can be arbitrary but the default convention is to prefix it with
read_. The macro :c:macro:ALICE_ADD_FILE_TYPEtogether :c:macro:ALICE_READ_FILEwill automatically add a read command calledread_<tagname>.- Parameters
name: Name of the commandlabel: Label for the file type (used in help string)
-
template <typename Tag>
voidinsert_write_command(const std::string &name, const std::string &label)¶ Inserts a write command.
Inserts a writ command for a given file tag. The name of the command can be arbitrary but the default convention is to prefix it with
write_. The macro :c:macro:ALICE_ADD_FILE_TYPEtogether :c:macro:ALICE_WRITE_FILEwill automatically add a write command calledwrite_<tagname>.- Parameters
name: Name of the commandlabel: Label for the file type (used in help string)
-
int
run(int argc, char **argv)¶ Runs the shell.
This function is only used if the CLI is used in stand-alone mode, not when used as Python module. The values
argcandargvcan be taken from themainfunction. For some flags, such as-fand-c, the CLI will read commands from a file or the command line, respectively, and then stop (unless flag-iis set). Otherwise, the CLI will enter a loop that accepts commands as user inputer.- Parameters
argc: Number of arguments (incl. program name, likeargcinmain)argv: Argument values (likeargvinmain)
-