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

This commit is contained in:
2026-02-05 20:56:12 +00:00
parent 5c84cd0fde
commit d87ba16cfd

70
src/commands/tag.py Normal file
View File

@@ -0,0 +1,70 @@
"""Tag management CLI commands."""
from typing import Optional
import click
from ..storage import PromptStorage
@click.group()
def tag_cmd():
"""Manage tags."""
pass
@tag_cmd.command("list")
@click.option("--dir", "prompt_dir", default=None, help="Prompt directory")
def list_tags(prompt_dir: Optional[str]):
"""List all tags."""
from rich.console import Console
from rich.table import Table
storage = PromptStorage(prompt_dir)
tags = storage.list_tags()
table = Table(title="Tags")
table.add_column("Tag", style="cyan")
table.add_column("Count", style="magenta")
table.add_column("Prompts", style="green")
for tag_name in tags:
tag = storage.get_tag(tag_name)
count = len(tag.prompts) if tag else 0
prompts_str = ", ".join(tag.prompts[:5]) + ("..." if len(tag.prompts) > 5 else "") if tag and tag.prompts else "-"
table.add_row(tag_name, str(count), prompts_str)
console = Console()
console.print(table)
@tag_cmd.command("add")
@click.argument("prompt_name")
@click.argument("tag")
@click.option("--dir", "prompt_dir", default=None, help="Prompt directory")
def add_tag(prompt_name: str, tag: str, prompt_dir: Optional[str]):
"""Add a tag to a prompt."""
storage = PromptStorage(prompt_dir)
if not storage.prompt_exists(prompt_name):
click.echo(f"Error: Prompt '{prompt_name}' not found", err=True)
return
storage.add_tag_to_prompt(prompt_name, tag)
click.echo(f"Added tag '{tag}' to prompt '{prompt_name}'")
@tag_cmd.command("remove")
@click.argument("prompt_name")
@click.argument("tag")
@click.option("--dir", "prompt_dir", default=None, help="Prompt directory")
def remove_tag(prompt_name: str, tag: str, prompt_dir: Optional[str]):
"""Remove a tag from a prompt."""
storage = PromptStorage(prompt_dir)
result = storage.remove_tag_from_prompt(prompt_name, tag)
if result:
click.echo(f"Removed tag '{tag}' from prompt '{prompt_name}'")
else:
click.echo(f"Error: Tag '{tag}' not found on prompt '{prompt_name}'", err=True)