Skip to content

Commit 39c5ef1

Browse files
authored
fix(agentstack-cli): display help on no-args (#1764)
1 parent 1481c75 commit 39c5ef1

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

apps/agentstack-cli/src/agentstack_cli/__init__.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,14 @@
1616
import agentstack_cli.commands.self
1717
import agentstack_cli.commands.server
1818
import agentstack_cli.commands.user
19-
from agentstack_cli.async_typer import AliasGroup, AsyncTyper
19+
from agentstack_cli.async_typer import AsyncTyper
2020
from agentstack_cli.configuration import Configuration
2121

2222
logging.basicConfig(level=logging.INFO if Configuration().debug else logging.FATAL)
2323
logging.getLogger("httpx").setLevel(logging.WARNING) # not sure why this is necessary
2424

2525

26-
class RootHelpGroup(AliasGroup):
27-
def get_help(self, ctx):
28-
return """\
26+
HELP_TEXT = """\
2927
Usage: agentstack [OPTIONS] COMMAND [ARGS]...
3028
3129
╭─ Getting Started ──────────────────────────────────────────────────────────╮
@@ -63,7 +61,19 @@ def get_help(self, ctx):
6361
"""
6462

6563

66-
app = AsyncTyper(no_args_is_help=True, cls=RootHelpGroup)
64+
app = AsyncTyper()
65+
66+
67+
@app.callback(invoke_without_command=True)
68+
def main(
69+
ctx: typer.Context,
70+
help: bool = typer.Option(False, "--help", help="Show this message and exit."),
71+
):
72+
if help or ctx.invoked_subcommand is None:
73+
typer.echo(HELP_TEXT)
74+
raise typer.Exit()
75+
76+
6777
app.add_typer(agentstack_cli.commands.model.app, name="model", no_args_is_help=True, help="Manage model providers.")
6878
app.add_typer(agentstack_cli.commands.agent.app, name="agent", no_args_is_help=True, help="Manage agents.")
6979
app.add_typer(

0 commit comments

Comments
 (0)