clipstick
clipstick copied to clipboard
create cli applications using pydantic models
This is helpful, when list of CLI args comes not from `sys.argv` and, as result, entry point cannot be parsed from `sys.argv[0]`. This is also might be helpful for cases,...
when you are calling your cli as a module which has a `__main__.py` entrypoint your help output shows like this: ``` Usage: __main__.py [Arguments] [Options] ``` which is not very...
Consider this code: ```python from cli.Config import Load as LoadConfig class Main(BaseModel): sub_command: LoadConfig | Delete # the LoadConfig is important here. ``` In help output the original "load" command...
Sometimes (many times ?) it is unncecessary to display typing info in your help as the help text (the docstring) itself is descriptive enough to not need the typing information.
In this case: ```python # clipstick_cmds.py from clipstick import parse from pydantic import BaseModel class AlfaCmd(BaseModel): """Hacer cosas de alfa""" uno: str """Parámetro para alfa""" def run(self): print(f"alfa {self.uno}") class...
Given ```python # adder1.py from clipstick import parse from pydantic import BaseModel class Adder(BaseModel): ints: int def run(self): print(sum([self.ints])) cmd = parse(Adder) cmd.run() ``` this runs OK: ```bash $ adder1.py...