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 the flext-oracle-oic extension provides a unified entry point for performing Oracle Integration Cloud (OIC) operations. It is built using the FLEXT CLI Pattern, which leverages the flext-cli facade to expose Pydantic-driven commands for enterprise integration management.
The CLI serves as the primary tool for administrators and developers to interact with OIC instances, allowing for connection testing, integration discovery, and version management through a standardized terminal interface.
Sources: src/flext_oracle_oic/main.py:1-12, pyproject.toml:39-42
CLI Architecture and Entry Points
The CLI is structured around the FlextOracleOicCli class, which manages the application lifecycle and command registration. The execution flow begins at a main function that uses cli.execute_app to dispatch user input to the appropriate command handlers.
Application Metadata
| Property | Value | Source |
|---|---|---|
| App Name | flext-oracle-oic-ext | src/flext_oracle_oic/main.py:110 |
| Executable Scripts | flext-oracle-oic, oracle-oic-ext | pyproject.toml:79-80 |
| Library Version | 0.12.0-dev | pyproject.toml:36 |
Core Components
The architecture follows a railway-oriented error handling approach, where commands are encapsulated as Pydantic models (inheriting from s[bool]) and executed via the FlextOracleOicService.
The diagram above shows the flow from user input through the CLI dispatch mechanism to the underlying service layer.
Sources: src/flext_oracle_oic/main.py:102-125, src/flext_oracle_oic/main.py:137-145
Command Reference
The CLI registers three primary commands, each mapped to a specific internal command class.
1. Test Connection
The test-connection command probes the configured Oracle OIC endpoint to verify connectivity. It initializes a development-grade settings object and utilizes the service context manager to validate the connection.
- Command Class:
_TestConnectionCommand - Logic: Executes
service.test_connection()and prints success or failure messages to the console using theclifacade.
Sources: src/flext_oracle_oic/main.py:30-48
2. List Integrations
The list-integrations command enumerates published integrations within the OIC instance. It provides a formatted summary of integration metadata.
- Command Class:
_ListIntegrationsCommand - Output Columns: Integration Name, ID, Status, Version, and Description.
Sources: src/flext_oracle_oic/main.py:51-68
3. Version
Prints the current version of the Oracle OIC Extension.
- Command Class:
_ShowVersionCommand - Output Example:
Oracle OIC Extension v0.12.0-dev
Sources: src/flext_oracle_oic/main.py:71-79
Execution Sequence
When a command like list-integrations is executed, the following sequence occurs within the system:
This sequence illustrates the interaction between the result routes and the command execution logic.
Sources: src/flext_oracle_oic/main.py:51-68, src/flext_oracle_oic/main.py:125-135
Implementation Details
The CLI implementation relies on several key patterns:
- Lazy Exporting: The
FlextOracleOicCliis exposed viasrc/flext_oracle_oic/__init__.pyusing a lazy import mechanism to optimize startup time. - Result Pattern: All commands return a
p.Result[bool], ensuring that errors (such asc.EXC_NETWORK_TYPE) are captured and handled gracefully without crashing the CLI. - Dependency Management: The CLI depends on
typerfor application routing andflext-clifor formatting and result management.
# From src/flext_oracle_oic/main.py:137-145
def main(args: t.StrSequence | None = None) -> int:
"""Run main CLI entry point - FLEXT CLI Pattern."""
app = FlextOracleOicCli.build_app()
try:
outcome = cli.execute_app(
app,
prog_name=FlextOracleOicCli.APP_NAME,
args=list(args) if args is not None else sys.argv[1:],
)
except KeyboardInterrupt:
return 130
return 0 if outcome.success else 1
Sources: src/flext_oracle_oic/main.py:137-152, src/flext_oracle_oic/init.py:45-89, pyproject.toml:50
Conclusion
The flext-oracle-oic CLI provides a robust, type-safe interface for managing OIC integrations. By leveraging the FLEXT CLI Pattern, it maintains consistency with other FLEXT tools while providing specific functionality for Oracle Integration Cloud environments, including connection probing and integration listing.
Sources: src/flext_oracle_oic/main.py:1-12