diff --git a/clea/__init__.py b/clea/__init__.py index fde8cc7..2944452 100644 --- a/clea/__init__.py +++ b/clea/__init__.py @@ -3,6 +3,7 @@ """ from .context import Context # noqa: F401 +from .exceptions import CleaException # noqa: F401 from .params import ( # noqa: F401 Boolean, Choice, @@ -18,4 +19,3 @@ ) from .runner import run # noqa: F401 from .wrappers import command, group # noqa: F401 -from .exceptions import CleaException # noqa: F401 diff --git a/examples/add.py b/examples/add.py index d9a9a7f..754de7c 100644 --- a/examples/add.py +++ b/examples/add.py @@ -2,9 +2,7 @@ from typing_extensions import Annotated -from clea.params import Integer -from clea.runner import run -from clea.wrappers import command +from clea import Integer, command, run @command diff --git a/examples/add_numbers.py b/examples/add_numbers.py new file mode 100644 index 0000000..41d6898 --- /dev/null +++ b/examples/add_numbers.py @@ -0,0 +1,19 @@ +"""Simple add program with custom command name.""" + +from typing_extensions import Annotated + +from clea import Integer, command, run + + +@command(name="add-numbers") +def add( + n1: Annotated[int, Integer()], + n2: Annotated[int, Integer()], +) -> None: + """Add two numbers""" + + print(f"Total {n1 + n2}") + + +if __name__ == "__main__": # pragma: nocover + run(cli=add) diff --git a/examples/calculator.py b/examples/calculator.py index 9ef2291..72603fb 100644 --- a/examples/calculator.py +++ b/examples/calculator.py @@ -3,9 +3,7 @@ from typing_extensions import Annotated -from clea.params import Boolean, Integer -from clea.runner import run -from clea.wrappers import group +from clea import Boolean, Integer, group, run @group