PK!IHHdecli/__init__.pyfrom .application import cli __version__ = "0.3.1" __all__ = ("cli",) PK!decli/application.pyimport argparse from typing import Optional, Callable, Union def handle_name(name: Union[str, list]) -> list: if isinstance(name, str): name = [name] return name def add_arguments(parser, args: list): for arg in args: name = handle_name(arg.pop("name")) parser.add_argument(*name, **arg) def add_subcommand(parser, command: dict): args: list = command.pop("arguments", None) func: Optional[Callable] = command.pop("func", None) names: list = handle_name(command.pop("name")) name: str = names.pop(0) if names: command.update({"aliases": names}) command_parser = parser.add_parser(name, **command) if func: command_parser.set_defaults(func=func) if args: add_arguments(command_parser, args) def add_subparser(parser, subcommand): commands: list = subcommand.pop("commands") subparser = parser.add_subparsers(**subcommand) for command in commands: add_subcommand(subparser, command) def add_parser(data: dict, parser_class: Callable, parents: Optional[list]): if parents is None: parents = [] args: Optional[list] = data.pop("arguments", None) subcommands: Optional[dict] = data.pop("subcommands", None) parser = parser_class(**data, parents=parents) if args: add_arguments(parser, args) if subcommands: add_subparser(parser, subcommands) return parser def cli( data: dict, parser_class: Callable = argparse.ArgumentParser, parents: Optional[list] = None, ): """Create a cli application. This is the entrypoint. """ parser = add_parser(data, parser_class, parents) return parser PK!SO1))decli-0.3.1.dist-info/LICENSEMIT License Copyright (c) 2018 Santiago Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER I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