Пример #1
0
def get_command_name(args):
    """
    Return name of command which is being run
    """

    # First argument would always be atlas or manage.py, i.e the calling interface
    if len(args) < 2:
        CommandError.print_to_err(
            f"Name of command missing. Valid commands are - {VALID_COMMANDS}")

    return args[1]
Пример #2
0
    def execute(self):
        command_path = self.fetch_command()

        if not command_path:
            CommandError.print_to_err(
                f"Invalid command. Valid commands are - {VALID_COMMANDS}")

        parser = ArgumentParser(usage="%(prog)s subcommand [options] [args]",
                                add_help=False)
        parser.add_argument('--pythonpath')
        parser.add_argument('args', nargs='*')  # catch-all

        options = parser.parse_known_args(self.args[2:])[0]
        handle_default_options(options)

        command_class = self.load_command(command_path)

        return command_class.run_from_argv(self.args)