Skip to content

Commit

Permalink
Merge pull request #137 from opentensor/feat/thewhaleking/help-when-n…
Browse files Browse the repository at this point in the history
…o-cmd-specified

Automatic Help text when no command specified
  • Loading branch information
thewhaleking authored Sep 30, 2024
2 parents e22d3fe + b31aa2b commit e6fc91f
Showing 1 changed file with 38 additions and 13 deletions.
51 changes: 38 additions & 13 deletions bittensor_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,10 @@ def __init__(self):
self.config_path = os.path.expanduser(defaults.config.path)

self.app = typer.Typer(
rich_markup_mode="rich", callback=self.main_callback, epilog=_epilog
rich_markup_mode="rich",
callback=self.main_callback,
epilog=_epilog,
no_args_is_help=True,
)
self.config_app = typer.Typer(epilog=_epilog)
self.wallet_app = typer.Typer(epilog=_epilog)
Expand All @@ -437,61 +440,80 @@ def __init__(self):
self.config_app,
name="config",
short_help="Config commands, aliases: `c`, `conf`",
no_args_is_help=True,
)
self.app.add_typer(self.config_app, name="conf", hidden=True)
self.app.add_typer(self.config_app, name="c", hidden=True)
self.app.add_typer(
self.config_app, name="conf", hidden=True, no_args_is_help=True
)
self.app.add_typer(self.config_app, name="c", hidden=True, no_args_is_help=True)

# wallet aliases
self.app.add_typer(
self.wallet_app,
name="wallet",
short_help="Wallet commands, aliases: `wallets`, `w`",
no_args_is_help=True,
)
self.app.add_typer(self.wallet_app, name="w", hidden=True, no_args_is_help=True)
self.app.add_typer(
self.wallet_app, name="wallets", hidden=True, no_args_is_help=True
)
self.app.add_typer(self.wallet_app, name="w", hidden=True)
self.app.add_typer(self.wallet_app, name="wallets", hidden=True)

# root aliases
self.app.add_typer(
self.root_app,
name="root",
short_help="Root commands, alias: `r`",
no_args_is_help=True,
)
self.app.add_typer(self.root_app, name="r", hidden=True)
self.app.add_typer(self.root_app, name="r", hidden=True, no_args_is_help=True)

# stake aliases
self.app.add_typer(
self.stake_app,
name="stake",
short_help="Stake commands, alias: `st`",
no_args_is_help=True,
)
self.app.add_typer(self.stake_app, name="st", hidden=True)
self.app.add_typer(self.stake_app, name="st", hidden=True, no_args_is_help=True)

# sudo aliases
self.app.add_typer(
self.sudo_app,
name="sudo",
short_help="Sudo commands, alias: `su`",
no_args_is_help=True,
)
self.app.add_typer(self.sudo_app, name="su", hidden=True)
self.app.add_typer(self.sudo_app, name="su", hidden=True, no_args_is_help=True)

# subnets aliases
self.app.add_typer(
self.subnets_app,
name="subnets",
short_help="Subnets commands, alias: `s`, `subnet`",
no_args_is_help=True,
)
self.app.add_typer(
self.subnets_app, name="s", hidden=True, no_args_is_help=True
)
self.app.add_typer(
self.subnets_app, name="subnet", hidden=True, no_args_is_help=True
)
self.app.add_typer(self.subnets_app, name="s", hidden=True)
self.app.add_typer(self.subnets_app, name="subnet", hidden=True)

# weights aliases
self.app.add_typer(
self.weights_app,
name="weights",
short_help="Weights commands, aliases: `wt`, `weight`",
hidden=True,
no_args_is_help=True,
)
self.app.add_typer(
self.weights_app, name="wt", hidden=True, no_args_is_help=True
)
self.app.add_typer(
self.weights_app, name="weight", hidden=True, no_args_is_help=True
)
self.app.add_typer(self.weights_app, name="wt", hidden=True)
self.app.add_typer(self.weights_app, name="weight", hidden=True)

# config commands
self.config_app.command("set")(self.set_config)
Expand Down Expand Up @@ -613,8 +635,11 @@ def __init__(self):
name="child",
short_help="Child Hotkey commands, alias: `children`",
rich_help_panel=HELP_PANELS["STAKE"]["CHILD"],
no_args_is_help=True,
)
self.stake_app.add_typer(
children_app, name="children", hidden=True, no_args_is_help=True
)
self.stake_app.add_typer(children_app, name="children", hidden=True)
children_app.command("get")(self.stake_get_children)
children_app.command("set")(self.stake_set_children)
children_app.command("revoke")(self.stake_revoke_children)
Expand Down

0 comments on commit e6fc91f

Please sign in to comment.