Command Line Interface (CLI)
Relevant source files
The following files were used as context for generating this wiki page:
The Command Line Interface (CLI) for flext-target-oracle serves as the primary entry point for managing data loading operations and project interactions. It provides a structured way to validate configurations, initialize data loads, and retrieve project metadata. The CLI is built using a service-oriented architecture that maps user arguments to specific command execution objects, ensuring a clean separation between command parsing and business logic.
The interface is exposed through the flext-target-oracle and target-oracle executable scripts. It leverages the flext-cli framework to handle standard process exit semantics and logging, while using the internal OracleTargetCommandFactory to generate executable command objects based on user input.
Sources: src/flext_target_oracle/_utilities/cli.py:5-15, pyproject.toml:98-99
CLI Architecture and Service Layer
The CLI is managed by the FlextTargetOracleCliService, which handles the dispatching of arguments to appropriate command implementations. This service serves as a bridge between the system's sys.argv and the internal command model.
Dispatch Logic
The dispatch process identifies the requested command (e.g., validate, load, about) and invokes the OracleTargetCommandFactory to create the corresponding command object. If no arguments are provided or help is requested, the service returns a standard usage guide.
The flow shows how user input is routed through the CliService to factory-created commands before returning result status to the operating system.
Sources: src/flext_target_oracle/_utilities/cli.py:30-47
Command Models and Execution
Commands are implemented as Pydantic-based models within the FlextTargetOracleModelsCommands mixin. Each command encapsulates the parameters required for its specific task and defines an execute() method that returns a Result object.
Supported Commands
| Command | Description | Key Parameters |
|---|---|---|
validate | Validates settings and connectivity to the Oracle database. | config_file |
load | Prepares the target for data loading, initializing settings and state. | config_file, state_file |
about | Returns project information and metadata. | format (json/text) |
Sources: src/flext_target_oracle/_models/commands.py:16-105
Command Implementation Details
- Validate Command: Loads target settings from a provided JSON file and executes
validate_business_rules(). It ensures the configuration is semantically correct before attempting database operations. - Load Command: Initializes the target for data processing. It requires a configuration file and optionally a state file to support incremental loading patterns.
- About Command: Returns a JSON or text payload containing the package name (
flext-target-oracle) and description.
Sources: src/flext_target_oracle/_models/commands.py:30-80
Integration with FLEXT Client
While the CLI provides the entry point for shell execution, it utilizes the FlextTargetOracle client (the unified Singer target implementation) for the actual processing logic. The CLI load and validate commands act as wrappers around the client's initialize() and test_connection() methods.
The sequence illustrates how the CLI service coordinates with the target client to perform a validation check.
Sources: src/flext_target_oracle/_utilities/cli.py:35-40, src/flext_target_oracle/_utilities/client.py:20-50
Configuration and Entry Points
The project defines two primary scripts in pyproject.toml that point to the CLI entrypoint:
flext-target-oracletarget-oracle
Both scripts invoke flext_target_oracle.target:cli, which ultimately calls the main() function in the CLI utility module. This function initializes the FlextTargetOracleCliService, runs the dispatch logic, and uses flext_cli to exit with the appropriate status code (0 for success, 1 for failure).
Sources: pyproject.toml:98-99, src/flext_target_oracle/_utilities/cli.py:56-62
Error Handling
The CLI implements railway-oriented programming (ROP) through the use of Result types. If a command fails during execution, the finalize_cli_result method captures the error from the Result object, logs it via the fetch_logger, and ensures the process returns exit code 1.
Sources: src/flext_target_oracle/_utilities/cli.py:21-28, src/flext_target_oracle/_utilities/errors.py
The CLI provides a standardized interface for interacting with the Oracle target, ensuring that configuration validation and load initialization are handled consistently across different environments. By mapping shell commands to internal command models, the system maintains high testability and clear separation of concerns.