Skip to content

Commit 3c5d53a

Browse files
committed
feat(cli): add 'quanuxctl geminicli' command
- Helper command to easily install/remove the QuanuX Gemini Extension locally. - Usage: 'quanuxctl geminicli install' or 'quanuxctl gemini install'.
1 parent 4dd7a87 commit 3c5d53a

2 files changed

Lines changed: 70 additions & 1 deletion

File tree

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import typer
2+
import subprocess
3+
import sys
4+
from pathlib import Path
5+
from rich.console import Console
6+
7+
app = typer.Typer()
8+
console = Console()
9+
10+
def get_project_root() -> Path:
11+
"""Find the project root."""
12+
# Assuming this is run from within the repo, finding where 'quanuxctl' or 'server' is
13+
# Using the current file path
14+
current_file = Path(__file__).resolve()
15+
# Path: server/cli/src/quanuxctl/commands/geminicli.py
16+
# Root: ../../../../../../
17+
return current_file.parents[5]
18+
19+
@app.command()
20+
def install():
21+
"""
22+
Install the QuanuX Gemini CLI Extension locally.
23+
"""
24+
root = get_project_root()
25+
extension_path = root / "extensions" / "python" / "gemini-cli-extension"
26+
27+
if not extension_path.exists():
28+
console.print(f"[bold red]Error:[/bold red] Extension path not found: {extension_path}")
29+
raise typer.Exit(1)
30+
31+
console.print(f"[bold blue]Installing extension from:[/bold blue] {extension_path}")
32+
33+
try:
34+
# Check if gemini is installed
35+
subprocess.run(["gemini", "--version"], check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
36+
37+
# Install
38+
subprocess.run(["gemini", "extension", "install", str(extension_path)], check=True)
39+
console.print("[bold green]Successfully installed QuanuX Gemini Extension![/bold green]")
40+
41+
except FileNotFoundError:
42+
console.print("[bold red]Error:[/bold red] 'gemini' command not found. Please install Gemini CLI first.")
43+
raise typer.Exit(1)
44+
except subprocess.CalledProcessError as e:
45+
console.print(f"[bold red]Installation failed:[/bold red] {e}")
46+
raise typer.Exit(1)
47+
48+
@app.command()
49+
def remove():
50+
"""
51+
Remove the QuanuX Gemini CLI Extension.
52+
"""
53+
try:
54+
# Check if gemini is installed
55+
subprocess.run(["gemini", "--version"], check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
56+
57+
# Uninstall using the ID defined in gemini-extension.json
58+
subprocess.run(["gemini", "extension", "uninstall", "quanux-mcp"], check=True)
59+
console.print("[bold green]Successfully removed QuanuX Gemini Extension.[/bold green]")
60+
61+
except FileNotFoundError:
62+
console.print("[bold red]Error:[/bold red] 'gemini' command not found.")
63+
raise typer.Exit(1)
64+
except subprocess.CalledProcessError as e:
65+
console.print(f"[bold red]Removal failed:[/bold red] {e}")
66+
raise typer.Exit(1)

server/cli/src/quanuxctl/main.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"""
66
import typer
77
from rich.console import Console
8-
from .commands import secrets, bridge, skills, extensions, node, storage, indicators, module, vcs, dashboard, topstepx
8+
from .commands import secrets, bridge, skills, extensions, node, storage, indicators, module, vcs, dashboard, topstepx, geminicli
99
from . import __version__
1010

1111
app = typer.Typer(
@@ -52,6 +52,9 @@
5252
app.add_typer(topstepx.app, name="topstepx", help="Manage TopstepX Extension.")
5353
app.add_typer(topstepx.app, name="ts", help="Alias for topstepx", hidden=True)
5454

55+
app.add_typer(geminicli.app, name="geminicli", help="Manage Gemini CLI Integration.")
56+
app.add_typer(geminicli.app, name="gemini", help="Alias for geminicli", hidden=True)
57+
5558

5659
@app.command()
5760
def mcp():

0 commit comments

Comments
 (0)