Skip to content

Commit c1824e7

Browse files
authored
Merge pull request #33 from zhujian0805/main
simplify the cli arguments
2 parents d3efb44 + b791f2e commit c1824e7

14 files changed

+803
-111
lines changed

code_assistant_manager/cli/agents_commands.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ def fetch_agents(
209209

210210

211211
@agent_app.command("view")
212-
def view_agent(agent_key: str):
212+
def view_agent(agent_key: str = typer.Argument(..., help="Agent identifier")):
213213
"""View a specific agent."""
214214
manager = _get_agent_manager()
215215
agent = manager.get(agent_key)
@@ -250,6 +250,13 @@ def view_agent(agent_key: str):
250250
typer.echo()
251251

252252

253+
# Alias 'show' to 'view' for consistency with other commands
254+
@agent_app.command("show")
255+
def show_agent(agent_key: str = typer.Argument(..., help="Agent identifier")):
256+
"""Show details about a specific agent (alias for view)."""
257+
return view_agent(agent_key)
258+
259+
253260
@agent_app.command("install")
254261
def install_agent(
255262
agent_key: str = AGENT_KEY_ARGUMENT,
@@ -485,6 +492,14 @@ def remove_repo(
485492
raise typer.Exit(1)
486493

487494

495+
@agent_app.command("status")
496+
def agent_status(
497+
app_type: Optional[str] = APP_TYPE_OPTION_ALL,
498+
):
499+
"""Show agent installation status across apps (alias: installed)."""
500+
return list_installed_agents(app_type)
501+
502+
488503
@agent_app.command("installed")
489504
def list_installed_agents(
490505
app_type: Optional[str] = APP_TYPE_OPTION_ALL,

code_assistant_manager/cli/app.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ def _lazy_import_mcp_app():
3838
from code_assistant_manager.mcp.cli import app as mcp_app
3939
return mcp_app
4040

41+
def _lazy_import_extension_app():
42+
from code_assistant_manager.cli.extension_commands import extension_app
43+
return extension_app
44+
4145
# Module-level typer.Option constants to fix B008 linting errors
4246
from .options import (
4347
CONFIG_FILE_OPTION,
@@ -254,6 +258,10 @@ def _get_agent_app_impl():
254258
"""Wrapper that defers agent app import."""
255259
return _get_lazy_app(_lazy_import_agent_app, "agent")
256260

261+
def _get_extension_app_impl():
262+
"""Wrapper that defers extension app import."""
263+
return _get_lazy_app(_lazy_import_extension_app, "extension")
264+
257265
# Note: Due to how Typer works, the apps are still evaluated at import time.
258266
# The actual performance benefit comes from:
259267
# 1. The tools modules no longer being imported upfront (done in tools/__init__.py)
@@ -282,6 +290,9 @@ def _get_agent_app_impl():
282290
# Add the agent app as a subcommand to the main app (Claude Code agents)
283291
app.add_typer(_get_agent_app_impl(), name="agent")
284292
app.add_typer(_get_agent_app_impl(), name="ag", hidden=True)
293+
# Add the extension app as a subcommand to the main app (Gemini extensions)
294+
app.add_typer(_get_extension_app_impl(), name="extensions")
295+
app.add_typer(_get_extension_app_impl(), name="ext", hidden=True)
285296

286297

287298
@config_app.command("validate")

code_assistant_manager/cli/completion_commands.py

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def _generate_bash_completion() -> str:
8282
cword=$COMP_CWORD
8383
8484
# Main commands (visible and hidden aliases)
85-
commands="launch l config cf mcp m prompt p skill s plugin pl agent ag upgrade u install i uninstall un doctor d version v completion comp c --help --version --config --endpoints --debug -d"
85+
commands="launch l config cf mcp m prompt p skill s plugin pl agent ag extensions ext upgrade u install i uninstall un doctor d version v completion comp c --help --version --config --endpoints --debug -d"
8686
8787
# Tool names for launch command
8888
tools="claude codex copilot gemini droid qwen codebuddy iflow qodercli zed neovate crush cursor-agent"
@@ -102,6 +102,9 @@ def _generate_bash_completion() -> str:
102102
# Agent subcommands
103103
agent_commands="list fetch view install uninstall repos add-repo remove-repo installed uninstall-all"
104104
105+
# Extensions subcommands
106+
extensions_commands="browse install uninstall list update disable enable link new validate settings"
107+
105108
# Global flags
106109
global_flags="--help --version --config --endpoints --debug -d"
107110
@@ -155,6 +158,10 @@ def _generate_bash_completion() -> str:
155158
COMPREPLY=( $(compgen -W "${agent_commands}" -- ${cur}) )
156159
return 0
157160
;;
161+
extensions|ext)
162+
COMPREPLY=( $(compgen -W "${extensions_commands}" -- ${cur}) )
163+
return 0
164+
;;
158165
upgrade|u)
159166
COMPREPLY=( $(compgen -W "all ${tools} mcp --verbose -v" -- ${cur}) )
160167
return 0
@@ -393,6 +400,22 @@ def _generate_bash_completion() -> str:
393400
;;
394401
esac
395402
;;
403+
extensions|ext)
404+
case "${COMP_WORDS[2]}" in
405+
browse|list|new|settings)
406+
COMPREPLY=( $(compgen -W "--help" -- ${cur}) )
407+
return 0
408+
;;
409+
install|uninstall|update|disable|enable|validate)
410+
COMPREPLY=( $(compgen -W "--help" -- ${cur}) )
411+
return 0
412+
;;
413+
link)
414+
COMPREPLY=( $(compgen -W "--help" -- ${cur}) )
415+
return 0
416+
;;
417+
esac
418+
;;
396419
upgrade|u|install|i)
397420
case "${COMP_WORDS[2]}" in
398421
all|claude|codex|copilot|gemini|droid|qwen|codebuddy|iflow|qodercli|zed|neovate|crush|cursor-agent|mcp)
@@ -440,7 +463,7 @@ def _generate_zsh_completion() -> str:
440463
#compdef code-assistant-manager cam
441464
442465
_code_assistant_manager() {
443-
local -a commands tools mcp_server_commands config_commands prompt_commands skill_commands plugin_commands agent_commands global_flags
466+
local -a commands tools mcp_server_commands config_commands prompt_commands skill_commands plugin_commands agent_commands extensions_commands global_flags
444467
local context state line
445468
446469
commands=(
@@ -458,6 +481,8 @@ def _generate_zsh_completion() -> str:
458481
'pl:Alias for plugin'
459482
'agent:Agent management commands'
460483
'ag:Alias for agent'
484+
'extensions:Manage extensions for AI assistants'
485+
'ext:Alias for extensions'
461486
'upgrade:Upgrade CLI tools'
462487
'u:Alias for upgrade'
463488
'install:Install CLI tools'
@@ -564,6 +589,20 @@ def _generate_zsh_completion() -> str:
564589
'uninstall-all:Uninstall all agents'
565590
)
566591
592+
extensions_commands=(
593+
'browse:Browse available Gemini extensions'
594+
'install:Install a Gemini extension'
595+
'uninstall:Uninstall a Gemini extension'
596+
'list:List installed Gemini extensions'
597+
'update:Update Gemini extensions'
598+
'disable:Disable a Gemini extension'
599+
'enable:Enable a Gemini extension'
600+
'link:Link a local Gemini extension'
601+
'new:Create a new Gemini extension'
602+
'validate:Validate a Gemini extension'
603+
'settings:Manage Gemini extension settings'
604+
)
605+
567606
global_flags=(
568607
'--help[Show help]'
569608
'--version[Show version]'
@@ -748,6 +787,23 @@ def _generate_zsh_completion() -> str:
748787
esac
749788
fi
750789
;;
790+
extensions|ext)
791+
if (( CURRENT == 2 )); then
792+
_describe -t extensions_commands 'extensions command' extensions_commands
793+
else
794+
case $words[2] in
795+
browse|list|new|settings)
796+
_values 'option' '--help[Show help]'
797+
;;
798+
install|uninstall|update|disable|enable|validate|link)
799+
_values 'option' '--help[Show help]'
800+
;;
801+
*)
802+
_values 'option' '--help[Show help]'
803+
;;
804+
esac
805+
fi
806+
;;
751807
upgrade|u|install|i)
752808
if (( CURRENT == 2 )); then
753809
local -a upgrade_targets

0 commit comments

Comments
 (0)