Skip to content

Commit 5111532

Browse files
authored
Update cli.py
Signed-off-by: Mithun Gowda B <[email protected]>
1 parent f533dd9 commit 5111532

File tree

1 file changed

+85
-8
lines changed

1 file changed

+85
-8
lines changed

SuperQwen/setup/cli.py

Lines changed: 85 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import sys
22
import typer
33
import subprocess
4-
import time
4+
from typing import Optional
55
from typing_extensions import Annotated
66

77
from .. import __version__
@@ -14,12 +14,46 @@
1414
# --- Setup ---
1515
COMPONENTS = ["commands", "modes", "agents", "mcp"]
1616

17+
def version_callback(value: bool):
18+
if value:
19+
ui.display_info(f"SuperQwen Framework Version: {__version__}")
20+
raise typer.Exit()
21+
1722
app = typer.Typer(
1823
name="superqwen",
1924
help="SuperQwen Framework CLI - A tool to manage your Qwen CLI enhancements.",
2025
add_completion=False,
21-
rich_markup_mode="rich", # This can stay, Typer uses it for its own help formatting
2226
)
27+
28+
@app.callback(invoke_without_command=True)
29+
def main_callback(
30+
ctx: typer.Context,
31+
version: Optional[bool] = typer.Option(
32+
None,
33+
"--version",
34+
"-v",
35+
help="Show the application's version and exit.",
36+
callback=version_callback,
37+
is_eager=True,
38+
),
39+
help_flag: Optional[bool] = typer.Option(
40+
None,
41+
"--help",
42+
"-h",
43+
help="Show the help message and exit.",
44+
is_eager=True,
45+
)
46+
):
47+
"""
48+
Manage the SuperQwen Framework.
49+
"""
50+
if help_flag:
51+
help() # Call the custom help command
52+
raise typer.Exit()
53+
54+
if ctx.invoked_subcommand is None:
55+
help() # Show help if no command is provided
56+
2357
install_app = typer.Typer(name="install", help="Install framework components.")
2458
uninstall_app = typer.Typer(name="uninstall", help="Uninstall framework components.")
2559
app.add_typer(install_app)
@@ -44,11 +78,9 @@ def install_all_cmd():
4478
for i, component in enumerate(COMPONENTS, 1):
4579
ui.display_step(i, total_components, f"Installing {component}...")
4680

47-
progress_bar = ui.ProgressBar(100, prefix=f"{component.capitalize()}: ")
48-
INSTALL_MAP[component]() # Call the actual install function
49-
for j in range(101):
50-
time.sleep(0.01)
51-
progress_bar.update(j)
81+
# Create a progress bar with a dummy total, the installer function will set the real total.
82+
progress_bar = ui.ProgressBar(1, prefix=f"{component.capitalize()}: ")
83+
INSTALL_MAP[component](progress_bar=progress_bar) # Pass the progress bar
5284
progress_bar.finish()
5385

5486
ui.display_success("\n✅ All components installed successfully!")
@@ -96,9 +128,11 @@ def uninstall_all_cmd():
96128
for i, component in enumerate(COMPONENTS, 1):
97129
ui.display_step(i, total_components, f"Uninstalling {component}...")
98130

131+
# We can't show real progress for uninstall, so we'll keep the simulation here
99132
progress_bar = ui.ProgressBar(100, prefix=f"{component.capitalize()}: ")
100-
UNINSTALL_MAP[component]() # Call the actual uninstall function
133+
UNINSTALL_MAP[component]()
101134
for j in range(101):
135+
import time
102136
time.sleep(0.01)
103137
progress_bar.update(j)
104138
progress_bar.finish()
@@ -129,6 +163,49 @@ def uninstall_mcp_cmd():
129163
UNINSTALL_MAP["mcp"]()
130164
ui.display_success("MCP Config uninstalled.")
131165

166+
@app.command()
167+
def help():
168+
"""Show this message and exit."""
169+
ui.display_header("SuperQwen Framework", f"Version {__version__}")
170+
171+
ui.display_info("Usage: superqwen [OPTIONS] COMMAND [ARGS]...")
172+
173+
core_headers = ["Command", "Description"]
174+
core_rows = [
175+
["install", "Install framework components (run interactively)."],
176+
["install all", "Install all components non-interactively."],
177+
["uninstall", "Uninstall framework components (run interactively)."],
178+
["uninstall all", "Uninstall all components non-interactively."],
179+
["update", "Update the SuperQwen package to the latest version."],
180+
["help, --help, -h", "Show this help message."],
181+
["--version, -v", "Show the application's version and exit."],
182+
]
183+
ui.display_table(core_headers, core_rows, title="Core Commands")
184+
185+
sq_headers = ["Slash Command", "Description"]
186+
sq_rows = [
187+
["/sq:analyze", "Comprehensive code analysis."],
188+
["/sq:build", "Build, compile, and package projects."],
189+
["/sq:cleanup", "Clean up code and optimize project structure."],
190+
["/sq:design", "Design system architecture and interfaces."],
191+
["/sq:document", "Generate focused documentation."],
192+
["/sq:estimate", "Provide development estimates for tasks."],
193+
["/sq:explain", "Provide clear explanations of code and concepts."],
194+
["/sq:git", "Git operations with intelligent commit messages."],
195+
["/sq:help", "List all available /sq commands."],
196+
["/sq:implement", "Feature and code implementation."],
197+
["/sq:improve", "Apply systematic improvements to code."],
198+
["/sq:index", "Generate comprehensive project documentation."],
199+
["/sq:load", "Load session context via MCP."],
200+
["/sq:reflect", "Task reflection and validation via MCP."],
201+
["/sq:save", "Persist session context via MCP."],
202+
["/sq:select-tool", "Intelligent MCP tool selection."],
203+
["/sq:test", "Execute tests with coverage analysis."],
204+
["/sq:troubleshoot", "Diagnose and resolve issues."],
205+
]
206+
ui.display_table(sq_headers, sq_rows, title="Available /sq Commands")
207+
ui.display_warning("Note: /sq commands do not accept flags. All text following the command is treated as a single prompt.")
208+
132209
@app.command()
133210
def update():
134211
"""

0 commit comments

Comments
 (0)