Command Line#
The fitrequest tool automatically generates a command-line interface (CLI) based on the methods it creates.
Each class includes a cli_run method that launches a Typer application containing all the generated methods from fitrequest.
This setup ensures that configuration validation and authentication are seamlessly handled.
Additionally, the output is formatted using the rich library, which enhances readability with color-coding. This feature makes it straightforward to test the generated requests quickly and efficiently.
To utilize the CLI tool, simply add the cli_run function as a console script in your project’s pyproject.toml file, as demonstrated below.
Note
When the kwargs argument is included in the method signature, some httpx.request arguments are added and made available as options.
Note
Private methods (starting with an underscore _) will not be exposed to the CLI.
[project.scripts]
restapi-cli = "tests.demo_lazy_config_request_params:RestApiClient.cli_run"
Below some examples of output:
restapi-cli --help
restapi-cli get-item --help
restapi-cli get-items --help