cmeta.cli module
СMeta core class and functions
cMeta author and developer: (C) 2025-2026 Grigori Fursin
See the cMeta COPYRIGHT and LICENSE files in the project root for details.
Functions
- cmeta.cli.catch(result: dict)[source]
Check result dictionary for errors and exit if error is found.
- Parameters:
result (dict) – Dictionary that must contain a “return” key
- Raises:
SystemExit – If return code is greater than 0, exits with that code
- cmeta.cli.main(args=None) int[source]
Main function for CLI entry point. Processes sys.argv and calls CMeta.
Parses command-line arguments from sys.argv, processes them through the CMeta framework, and handles the results including error checking and exit codes.
- Returns:
Exit code (0 for success, non-zero for errors).
- Return type:
int
- cmeta.cli.main_cmeta() int[source]
Entry point for the ‘cmeta’ command-line interface.
- Returns:
Exit code (0 for success, non-zero for errors).
- Return type:
int
- cmeta.cli.main_cserver() int[source]
Entry point for the ‘cserver’ command-line interface.
- Returns:
Exit code (0 for success, non-zero for errors).
- Return type:
int
- cmeta.cli.main_cx() int[source]
Entry point for the ‘cx’ command-line interface.
- Returns:
Exit code (0 for success, non-zero for errors).
- Return type:
int
- cmeta.cli.main_meta() int[source]
Entry point for the ‘meta’ command-line interface.
- Returns:
Exit code (0 for success, non-zero for errors).
- Return type:
int
- cmeta.cli.process(cmd: list)[source]
Process command line arguments and execute CMeta operations.
This function parses command-line arguments, initializes the CMeta framework, and executes the requested category command. It handles global flags, category detection, and command routing.
- Parameters:
cmd (list) – Command line arguments as a list of strings. The original list is not modified.
- Returns:
- A CMeta dictionary with the following keys:
return (int): 0 for success, >0 for error codes.
error (str): Error message if return > 0.
Other keys depend on the executed command.
- Return type:
dict
Constants
- cmeta.cli.cli_init_params_desc = [{'desc': 'Specify path with CMeta repositories', 'key': 'home', 'space_before': True, 'types': [<class 'str'>, <class 'bool'>]}, {'desc': 'Enable debug mode (sets log_level to "DEBUG" and fail_on_error to True)', 'key': 'debug', 'type': <class 'bool'>}, {'aliases': ['fail', 'fail-on-error'], 'desc': 'Raise exception on first error for debugging', 'key': 'fail_on_error', 'type': <class 'bool'>}, {'aliases': ['log-level'], 'desc': 'Set logging level (e.g., debug, info, warning, error)', 'key': 'log_level', 'type': <class 'str'>, 'values': ['DEBUG', 'INFO', 'WARNING', 'WARN', 'ERROR', 'CRITICAL', 'FATAL']}, {'aliases': ['log-file'], 'desc': 'Specify file for logging', 'key': 'log_file', 'type': <class 'str'>}, {'aliases': ['pif'], 'desc': 'Pause before exiting in case of errors', 'key': 'pause_if_error', 'type': <class 'bool'>}]
Built-in mutable sequence.
If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.
- cmeta.cli.cli_params_desc = [{'aliases': ['h'], 'desc': 'Show help', 'key': 'help', 'type': <class 'bool'>}, {'aliases': ['v'], 'desc': 'Show version', 'key': 'version', 'type': <class 'bool'>}, {'desc': 'Reindex all artifacts', 'key': 'reindex', 'type': <class 'bool'>}, {'aliases': ['v'], 'desc': 'Use verbose output', 'key': 'verbose', 'type': <class 'bool'>}, {'desc': 'Call common commands from the base category', 'key': 'base', 'space_before': True, 'type': <class 'bool'>}, {'desc': 'Choose category API version', 'key': 'api', 'type': <class 'int'>}]
Built-in mutable sequence.
If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.
- cmeta.cli.fail_on_error = False
bool(x) -> bool
Returns True when the argument x is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.
- cmeta.cli.params_command2_desc = [{'desc': 'Category name (taken from the 1st argument from CLI)', 'key': 'category', 'skip_from_help': True, 'types': [<class 'str'>, <class 'dict'>]}, {'desc': 'Command (taken from the 2st argument from CLI)', 'key': 'command', 'skip_from_help': True, 'type': <class 'str'>}, {'desc': 'Force output to console', 'key': 'con', 'space_before': True, 'type': <class 'bool'>}, {'aliases': ['j'], 'desc': 'Print command output as JSON', 'key': 'json', 'type': <class 'bool'>}, {'aliases': ['json-file', 'jf'], 'desc': 'Specify json file to save command output', 'key': 'json_file', 'type': <class 'str'>}]
Built-in mutable sequence.
If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.