Skip to content

run

Create a Platitudes CLI out of a single function.

Platitudes provides to ways to generate CLIs: pl.Platitudes and pl.run. The latter, unlike a pl.Platitudes, doesn't allow to add subcommands to the CLI ala git add/fetch/... however it's much simpler to use as it only requires us to pass the function to pl.run.

Parameters:

Name Type Description Default
main Callable

The function that will form the base for the new CLI

required
arguments list[str] | None

List of strings passed for the CLI parsing. Defaults to using sys.argv.

None
config_file str | None

Name of the additional optional parameter that may be injected to provide default values via a json file. For more information on this functionality consult Config File Defaults

None
Example
import platitudes as pl

def hello_world(name: str = "World"):
    print(f"Hello {name}!")

pl.run(hello_world)