Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: --help option #31

Closed
wants to merge 2 commits into from
Closed
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
7 changes: 2 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]
name = "goose-ai"
description = "a programming agent that runs on your machine"
version = "0.8.3"
version = "0.8.4"
readme = "README.md"
requires-python = ">=3.10"
dependencies = [
Expand Down Expand Up @@ -46,7 +46,4 @@ requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.uv]
dev-dependencies = [
"pytest>=8.3.2",
"codecov>=2.1.13",
]
dev-dependencies = ["pytest>=8.3.2", "codecov>=2.1.13"]
22 changes: 15 additions & 7 deletions src/goose/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
from goose.utils import load_plugins
from goose.utils.session_file import list_sorted_session_files


@click.group()
def goose_cli() -> None:
pass


@goose_cli.command()
def version() -> None:
"""Lists the version of goose and any plugins"""
Expand Down Expand Up @@ -100,22 +102,28 @@ def session_clear(keep: int) -> None:
def get_session_files() -> Dict[str, Path]:
return list_sorted_session_files(SESSIONS_PATH)


all_cli_groups = load_plugins("goose.cli.group")
all_cli_group_options = load_plugins("goose.cli.group_option")


@click.group(
invoke_without_command=True,
name="goose",
help="AI-powered tool to assist in solving programming and operational tasks",)
# we only want to override --help if there are top-level command options
invoke_without_command=len(all_cli_group_options.items()) > 0,
name="goose",
help="AI-powered tool to assist in solving programming and operational tasks",
)
@click.pass_context
def cli(_: click.Context, **kwargs: Dict) -> None:
pass

all_cli_group_options = load_plugins("goose.cli.group_option")
for option in all_cli_group_options.values():
cli = option()(cli)

all_cli_groups = load_plugins("goose.cli.group")
for group in all_cli_groups.values():
for command in group.commands.values():
cli.add_command(command)

for option in all_cli_group_options.values():
cli = option()(cli)

if __name__ == "__main__":
cli()