fix: resolve CI/CD issues for Python project
Some checks failed
CI / test (push) Has been cancelled
CI / lint (push) Has been cancelled
CI / type-check (push) Has been cancelled

This commit is contained in:
2026-02-04 11:16:12 +00:00
parent 9a8e3dc3df
commit f5805db351

View File

@@ -1,22 +1,24 @@
"""CLI interface for ShellGenius.""" """CLI interface for ShellGenius."""
import os import os
import sys from typing import Optional
from typing import Any, Dict, Optional
import click import click
from prompt_toolkit import PromptSession
from prompt_toolkit.completion import WordCompleter
from rich.console import Console from rich.console import Console
from rich.panel import Panel from rich.panel import Panel
from rich.table import Table from rich.table import Table
from shellgenius.config import get_config 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.generation import ShellSafetyChecker, generate_shell
from shellgenius.history import HistoryLearner, get_history_storage from shellgenius.history import HistoryLearner, get_history_storage
from shellgenius.ollama_client import get_ollama_client from shellgenius.ollama_client import get_ollama_client
from shellgenius.refactoring import RefactoringAnalyzer, refactor_script from shellgenius.refactoring import refactor_script
console = Console() console = Console()
session: PromptSession[str] = PromptSession()
def print_header(): def print_header():
@@ -309,11 +311,10 @@ def interactive(ctx: click.Context):
while True: while True:
try: try:
choice = console.ask( choice = session.prompt(
"[bold cyan]ShellGenius[/bold cyan] > ", "[bold cyan]ShellGenius[/bold cyan] > ",
choices=["g", "e", "r", "h", "m", "q", "?"], completer=WordCompleter(["g", "e", "r", "h", "m", "q", "?"]),
default="?", ).strip() or "?"
)
if choice in ["q", "quit", "exit"]: if choice in ["q", "quit", "exit"]:
console.print("[cyan]Goodbye![/cyan]") console.print("[cyan]Goodbye![/cyan]")
@@ -332,7 +333,7 @@ def interactive(ctx: click.Context):
) )
) )
elif choice == "g": elif choice == "g":
desc = console.ask("[cyan]Describe what you want:[/cyan]") desc = session.prompt("[cyan]Describe what you want:[/cyan]")
if desc: if desc:
ctx.invoke( ctx.invoke(
generate, generate,
@@ -340,11 +341,11 @@ def interactive(ctx: click.Context):
shell="bash", shell="bash",
) )
elif choice == "e": 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): if path and os.path.exists(path):
ctx.invoke(explain, script_path=path) ctx.invoke(explain, script_path=path)
elif choice == "r": 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): if path and os.path.exists(path):
ctx.invoke(refactor, script_path=path, show_safe=True) ctx.invoke(refactor, script_path=path, show_safe=True)
elif choice == "h": elif choice == "h":