diff --git a/bittensor/cli.py b/bittensor/cli.py index 10b173a66b..49c2e0ab25 100644 --- a/bittensor/cli.py +++ b/bittensor/cli.py @@ -196,7 +196,7 @@ def __create_parser__() -> "argparse.ArgumentParser": help=command["help"], ) subparser = subcmd_parser.add_subparsers( - help=command["help"], dest="subcommand" + help=command["help"], dest="subcommand", required=True ) for subcommand in command["commands"].values(): @@ -241,19 +241,18 @@ def check_config(config: "bittensor.config"): command_data = COMMANDS[command] if isinstance(command_data, dict): - if config["subcommand"] == None: - # This probably isn't the best solution, refactor - for action in config["__parser"]._subparsers._actions: - if action.dest == "command" and action.choices[command]: - action.choices[command].print_help() - sys.exit() - - command_data["commands"][config["subcommand"]].check_config(config) + if config["subcommand"] != None: + command_data["commands"][config["subcommand"]].check_config(config) + else: + console.print( + f":cross_mark:[red]Missing subcommand for: {config.command}[/red]" + ) + sys.exit(1) else: command_data.check_config(config) else: console.print(f":cross_mark:[red]Unknown command: {config.command}[/red]") - sys.exit() + sys.exit(1) def run(self): """ diff --git a/bittensor/config.py b/bittensor/config.py index ac2c257248..3a879788ed 100644 --- a/bittensor/config.py +++ b/bittensor/config.py @@ -152,7 +152,6 @@ def __init__( params = config.__parse_args__(args=args, parser=parser, strict=strict) _config = self - _config["__parser"] = parser # Splits params and add to config config.__split_params__(params=params, _config=_config)