Core
Defines the main command-line interface (CLI) for the Simlify package.
This module provides the entry point for the Simlify command-line tool, allowing users to interact with Simlify's functionalities through various subcommands. It handles argument parsing, configuration loading, logging setup, and dispatches the execution to the appropriate subcommand based on user input.
cli_main()
¶
The main function that powers the Simlify command-line interface.
This function orchestrates the entire CLI process, from parsing user-provided arguments to executing the requested Simlify functionality. It performs the following key steps:
-
Argument Parsing: Utilizes the
create_parser
function to define and parse command-line arguments provided by the user. This includes top-level arguments and arguments specific to subcommands. -
Help Display: Checks if a subcommand was provided. If not, it prints the help message for the top-level parser to guide the user on available options and subcommands.
-
Logging Setup: Configures the logging system using the
setup_logging
function, which takes the parsed arguments (specifically logging-related arguments) to determine the logging level and output format. -
Version Information: Logs the Simlify version and the OASCI organization information to provide context about the running software.
-
Configuration Loading (Optional): Checks if the user provided a path to a YAML configuration file using the
--config
argument.- If a configuration file path is provided, it verifies the existence of the file. If the file does not exist, a critical error is logged, and the program exits.
- If the file exists, it loads the configuration using the
load_yaml_config
function. - The loaded configuration is then used to update the parsed arguments.
Command-line arguments take precedence over configuration file settings.
Only arguments that are not already set via the command line or are set to
None
are updated from the configuration file.
-
Subcommand Dispatch: Checks if a subcommand function (
func
) is associated with the parsed arguments. This association is typically established during the argument parsing process for each defined subcommand.- If a subcommand function is found, it is called with the parsed arguments as input, effectively executing the functionality associated with that subcommand.
- If no subcommand function is found (which should ideally be caught by the initial help check), it prints the help message for the top-level parser and exits with an error code, indicating that the user needs to provide a valid subcommand.
RAISES | DESCRIPTION |
---|---|
SystemExit
|
If the provided configuration file does not exist or if no valid subcommand is provided by the user. |