From f5805db35188d5b99bbaf736186e358da95d338d Mon Sep 17 00:00:00 2001 From: 7000pctAUTO Date: Wed, 4 Feb 2026 11:16:12 +0000 Subject: [PATCH] fix: resolve CI/CD issues for Python project --- shellgenius/cli.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/shellgenius/cli.py b/shellgenius/cli.py index 16c28ef..fcfb668 100644 --- a/shellgenius/cli.py +++ b/shellgenius/cli.py @@ -1,22 +1,24 @@ """CLI interface for ShellGenius.""" import os -import sys -from typing import Any, Dict, Optional +from typing import Optional import click +from prompt_toolkit import PromptSession +from prompt_toolkit.completion import WordCompleter from rich.console import Console from rich.panel import Panel from rich.table import Table from shellgenius.config import get_config -from shellgenius.explainer import ShellExplainer, explain_script +from shellgenius.explainer import explain_script from shellgenius.generation import ShellSafetyChecker, generate_shell from shellgenius.history import HistoryLearner, get_history_storage from shellgenius.ollama_client import get_ollama_client -from shellgenius.refactoring import RefactoringAnalyzer, refactor_script +from shellgenius.refactoring import refactor_script console = Console() +session: PromptSession[str] = PromptSession() def print_header(): @@ -309,11 +311,10 @@ def interactive(ctx: click.Context): while True: try: - choice = console.ask( + choice = session.prompt( "[bold cyan]ShellGenius[/bold cyan] > ", - choices=["g", "e", "r", "h", "m", "q", "?"], - default="?", - ) + completer=WordCompleter(["g", "e", "r", "h", "m", "q", "?"]), + ).strip() or "?" if choice in ["q", "quit", "exit"]: console.print("[cyan]Goodbye![/cyan]") @@ -332,7 +333,7 @@ def interactive(ctx: click.Context): ) ) elif choice == "g": - desc = console.ask("[cyan]Describe what you want:[/cyan]") + desc = session.prompt("[cyan]Describe what you want:[/cyan]") if desc: ctx.invoke( generate, @@ -340,11 +341,11 @@ def interactive(ctx: click.Context): shell="bash", ) elif choice == "e": - path = console.ask("[cyan]Path to script:[/cyan]") + path = session.prompt("[cyan]Path to script:[/cyan]") if path and os.path.exists(path): ctx.invoke(explain, script_path=path) elif choice == "r": - path = console.ask("[cyan]Path to script:[/cyan]") + path = session.prompt("[cyan]Path to script:[/cyan]") if path and os.path.exists(path): ctx.invoke(refactor, script_path=path, show_safe=True) elif choice == "h":