PK!7HHdecli/__init__.pyfrom .application import cli __version__ = "0.3.2" __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.2.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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