3faea003474f003d7576bd246c84484b9f9ed67a — fabrixxm 2 years ago 0b05d22
1 files changed, 47 insertions(+), 5 deletions(-)

M README.md => README.md +47 -5
@@ 5,7 5,6 @@ Each function will be a subcommand of your application.
*Climatik* define a function decorator which parse function definition and build
a subcommand command line parser.

## Docs

### def command(fnc:Callable)

@@ 13,8 12,26 @@ a subcommand command line parser.
Build subcommand from function

Subcommand name will be the function name and arguments are parsed to build the command line.
Optionally, subcommand name can be passed as parameter:

    def test():

Subcommands can be groupped passing `group_name` paramenter:

    def bar()

    def baz()

This two functions will be called from command line as `group bar` and `group baz`

Each positional argument will be a positional paramenter.

Each positional argument of the decorated function will be a positional paramenter.

Each optional argument will be an optional flag.

@@ 25,11 42,19 @@ An argument with `bool` type is converted to an optional flag parameter (with de
To create an optional positional paramenter, use the [`typing.Optional`](https://docs.python.org/3/library/typing.html#typing.Optional) type as hint with the parameter type, e.g. `Optional[str]`

Function docstring is used to set command's help and description.
To set arguments help string, add a line in docstring like

    @param argname : argument help


    def one(name, debug:bool, value="default", switchoff=True):
        "First subcommand"
        """First subcommand
        @param debug: enable debug output


@@ 60,8 85,8 @@ gives:

    optional arguments:
    -h, --help     show this help message and exit
    --value VALUE
    --debug        enable debug output
    --value VALUE  (default 'default')

    $ script two -h

@@ 76,6 101,23 @@ gives:
    -h, --help            show this help message and exit
    --long-param LONG_PARAM

### def group(name:str, help:str = "", description:str = "")

Set command group help and description

If a group named `name` does not exists, is created

Can be used also as a context manager. Each command defined in context will be added to the group

    with group('file', help="Manage files", description="Functions to manage files"):
        def ls():
        def rm():

### def run(prog:str=None, usage:str=None, description:str=None, **kwargs)

Run your application.