Initial upload: Local LLM Prompt Manager CLI tool
Some checks failed
CI / test (push) Has been cancelled
CI / lint (push) Has been cancelled
CI / build (push) Has been cancelled

This commit is contained in:
2026-02-05 20:56:19 +00:00
parent b2f70c2306
commit e1353b2346

68
src/commands/config.py Normal file
View File

@@ -0,0 +1,68 @@
"""Configuration CLI commands."""
from typing import Optional
import click
from ..config import ConfigManager
from ..llm import LLMClientFactory
@click.group()
def config_cmd():
"""Manage configuration."""
pass
@config_cmd.command("show")
def show_config():
"""Show current configuration."""
from rich.console import Console
from rich.table import Table
manager = ConfigManager()
config = manager.load()
table = Table(title="Configuration")
table.add_column("Setting", style="cyan")
table.add_column("Value", style="green")
for key, value in config.to_dict().items():
table.add_row(key, str(value))
console = Console()
console.print(table)
@config_cmd.command("set")
@click.argument("key")
@click.argument("value")
def set_config(key: str, value: str):
"""Set a configuration value."""
manager = ConfigManager()
valid_keys = ["prompt_dir", "ollama_url", "lmstudio_url", "default_model", "default_provider"]
if key not in valid_keys:
click.echo(f"Invalid key: {key}", err=True)
click.echo(f"Valid keys: {', '.join(valid_keys)}", err=True)
return
manager.set(key, value)
click.echo(f"Set {key} = {value}")
@config_cmd.command("test")
@click.option("--provider", default=None, help="Provider to test")
def test_connection(provider: Optional[str]):
"""Test LLM connection."""
client = LLMClientFactory.create(provider=provider)
if client.test_connection():
models = client.get_available_models()
click.echo("Connection successful!")
if models:
click.echo(f"Available models: {', '.join(models[:5])}")
else:
click.echo("Connection failed", err=True)
click.echo("Ensure the LLM service is running and check the API URL", err=True)