|
## Overview
|
|
## Overview
|
|
|
|
|
|
The OSDU CLI uses the [Python Click](https://click.palletsprojects.com/en/8.0.x/) package to simplify the development experience. Code is located under the _src\\osducli_ folder with _\_\_main\_\_.py_ containing the main entry point.
|
|
The OSDU CLI uses the [Python Click](https://click.palletsprojects.com/en/8.0.x/) package to simplify the development experience. Code is located under the _src/osducli_ folder as follows:
|
|
|
|
|
|
|
|
```text
|
|
|
|
├── commands <- CLI Commands grouped by folder
|
|
|
|
| ├── config/ <- Configuration commands
|
|
|
|
| ├── dataload/ <- Data loading commands
|
|
|
|
| ├── entitlements/ <- Entitlements commands
|
|
|
|
| ├── legal/ <- Legal commands
|
|
|
|
| ├── list/ <- List information
|
|
|
|
| ├── schema/ <- Schema commands
|
|
|
|
| ├── search/ <- Search commands
|
|
|
|
| ├── status/ <- Status commands
|
|
|
|
| ├── unit/ <- Unit commands
|
|
|
|
| ├── version/ <- Version command
|
|
|
|
| └── workflow/ <- Workflow commands
|
|
|
|
├── util <- Utility / helper functions
|
|
|
|
| ├── exceptions.py <- CLI specific exceptions
|
|
|
|
| ├── file.py <- File helper functions
|
|
|
|
| └── prompt.py <- Prompting for information
|
|
|
|
├── __init__.py <- Contains the CLI version number
|
|
|
|
├── __main__.py <- Main entry point and command loading
|
|
|
|
├── click_cli.py <- Click helpers including state and command decorators
|
|
|
|
├── cliclient.py <- Http client for working against OSDU API's
|
|
|
|
├── config.py <- For working with CLI configuration
|
|
|
|
├── log.py <- Logging functionality
|
|
|
|
└── state.py <- For working with CLI state
|
|
|
|
```
|
|
|
|
|
|
|
|
## Commands
|
|
|
|
|
|
The commands displayed in the CLI are automatically loaded based upon the file / folder structure in the _src/osducli/comands_ folder. All modules that contain a __click_command_ function are added as commands with the function docstring being used as the command help text. Subfolders can be used to provide groups of commands. In this case the docstring in the module _\_\_init\_\_.py_ is used as the group help text.
|
|
The commands displayed in the CLI are automatically loaded based upon the file / folder structure in the _src/osducli/comands_ folder. All modules that contain a __click_command_ function are added as commands with the function docstring being used as the command help text. Subfolders can be used to provide groups of commands. In this case the docstring in the module _\_\_init\_\_.py_ is used as the group help text.
|
|
|
|
|
|
__click_command_ functions should be decorated with the following:
|
|
__click_command_ functions (commands) should be decorated with the following:
|
|
|
|
|
|
- _handle_cli_exceptions_ - this provides common exception handling.
|
|
- _@handle_cli_exceptions_ - this provides common exception handling.
|
|
- One of:
|
|
- One of:
|
|
- _global_params_ - this provides --debug and --config parameters and would typically be used if you have a command that doesn't return any output.
|
|
- _@global_params_ - this provides --debug and --config parameters and would typically be used if you have a command that doesn't return any output.
|
|
- _command_with_output_ - should typically be used when you are returning information. This decorator provides the --output and --query parameters and that allow for customising the output format and specifying a jmes query to filter output. It also includes _global_params_
|
|
- _@command_with_output_ - should be used when you are returning information. This decorator provides the --output and --query parameters that allow for customising the output format and specifying a jmes query to filter output. It also includes _global_params_
|
|
|
|
|
|
## Calling OSDU API's
|
|
## Calling OSDU API's
|
|
|
|
|
... | | ... | |