|
|
## 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 folder with __main__.py containing the main entry point.
|
|
|
|
|
|
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 module __init__.py docstring is used as the group help text.
|
|
|
|
|
|
__click_command_ functions should be decorated with the following:
|
|
|
|
|
|
- _handle_cli_exceptions_ - this provides common exception handling.
|
|
|
- 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.
|
|
|
- _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_
|
|
|
|
|
|
## Calling OSDU API's
|
|
|
|
|
|
The cliclient.py module contains the _CliOsduClient _class that simplifies interacting with the OSDU backend. _CliOsduClient _currently uses the separate osdu-sdk package which contains backend code seperated out from the original CLI. Future updates might align with a future OSDU standard SDK. Using the _CliOsduClient_ you can make HTTP REST calls direclty agains the API's. Certain API's e.g. Search have wrapper classes that simplify the API usage.
|
|
|
|
|
|
## Testing
|
|
|
|
|
|
Test cases are provided for certain functionality and are located under the _tests_ folder. Extending coverage is an identified improvement area. |