Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions astrbot/cli/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import click

from . import __version__
from .commands import conf, init, password, plug, run
from .commands import config, init, password, plugin, run, service

logo_tmpl = r"""
___ _______.___________..______ .______ ______ .___________.
Expand All @@ -17,7 +17,23 @@
"""


@click.group()
class AstrBotCLIGroup(click.Group):
COMMAND_ALIASES = {
"conf": "config",
"plug": "plugin",
}

def get_command(self, ctx: click.Context, cmd_name: str) -> click.Command | None:
command = super().get_command(ctx, cmd_name)
if command is not None:
return command
alias_target = self.COMMAND_ALIASES.get(cmd_name)
if alias_target is None:
return None
return super().get_command(ctx, alias_target)


@click.group(cls=AstrBotCLIGroup)
@click.version_option(__version__, prog_name="AstrBot")
def cli() -> None:
"""The AstrBot CLI"""
Expand Down Expand Up @@ -52,9 +68,10 @@ def help(command_name: str | None) -> None:
cli.add_command(init)
cli.add_command(run)
cli.add_command(help)
cli.add_command(plug)
cli.add_command(conf)
cli.add_command(plugin)
cli.add_command(config)
cli.add_command(password)
cli.add_command(service)

if __name__ == "__main__":
cli()
10 changes: 7 additions & 3 deletions astrbot/cli/commands/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
from .cmd_conf import conf
from .cmd_conf import conf as config
from .cmd_init import init
from .cmd_password import password
from .cmd_plug import plug
from .cmd_plug import plug as plugin
from .cmd_run import run
from .cmd_service import service

__all__ = ["conf", "init", "password", "plug", "run"]
conf = config
plug = plugin

__all__ = ["config", "conf", "init", "password", "plugin", "plug", "run", "service"]
2 changes: 1 addition & 1 deletion astrbot/cli/commands/cmd_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def _set_dashboard_password(config: dict[str, Any], raw_password: str) -> None:
_set_nested_item(config, "dashboard.password_change_required", False)


@click.group(name="conf")
@click.group(name="config")
def conf() -> None:
"""Configuration management commands

Expand Down
2 changes: 1 addition & 1 deletion astrbot/cli/commands/cmd_plug.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
)


@click.group()
@click.group(name="plugin")
def plug() -> None:
"""Plugin management"""

Expand Down
Loading
Loading