Typer
https://typer.tiangolo.com/
Simplest CLI
import typer
def main(name: str):
print(f"Hello {name}")
if __name__ == "__main__":
typer.run(main)Hierarchical CLI (multiple entrypoints)
Please look through https://github.com/ezhang7423/language-control-diffusion/blob/main/src/lcd__main__.py
Save Config Files
The following is all gratefully borrowed from https://maxb2.github.io/typer-config/1.2.1/examples/save_config/. Please attribute all credit to maxb2.
This example shows you how save the parameters of the invoked command to a configuration file using the @dump_config decorator which operates on Typer commands (requested in issue #25).
An example typer app:
This package also provides
@dump_yaml_configand@dump_toml_configfor those file formats.If you put
@use_json_configbefore@dump_json_config, you will not capture theconfigparameter in your config dump. You probably want this behavior to avoid cascading config files.
And invoked with python:
Last updated
Was this helpful?