initial
This commit is contained in:
23 files changed
+2117
No files matched your search
@@ -0,0 +1,77 @@
|
||||
"""
|
||||
Main CLI for devtools.
|
||||
"""
|
||||
import click
|
||||
from rich.console import Console
|
||||
from rich.table import Table
|
||||
from .shared.config import Config
|
||||
from .gitignore.cli import cli as gitignore_cli
|
||||
from .commitgen.cli import cli as commit_cli
|
||||
|
||||
console = Console()
|
||||
|
||||
@click.group()
|
||||
def cli():
|
||||
"""Developer tools CLI."""
|
||||
pass
|
||||
|
||||
@cli.group()
|
||||
def config():
|
||||
"""Manage configuration."""
|
||||
pass
|
||||
|
||||
@config.command()
|
||||
@click.argument("key")
|
||||
@click.argument("value")
|
||||
def set(key: str, value: str):
|
||||
"""Set a configuration value."""
|
||||
config = Config()
|
||||
config.set(key, value)
|
||||
console.print(f"[green]Set {key} to {value}")
|
||||
|
||||
@config.command()
|
||||
@click.argument("key", required=False)
|
||||
def show(key: str = None):
|
||||
"""Show configuration values."""
|
||||
config = Config()
|
||||
if key:
|
||||
value = config.get(key)
|
||||
if value is None:
|
||||
console.print(f"[yellow]No value set for {key}")
|
||||
else:
|
||||
console.print(f"{key}: {value}")
|
||||
else:
|
||||
table = Table(title="Configuration")
|
||||
table.add_column("Key", style="cyan")
|
||||
table.add_column("Value", style="green")
|
||||
|
||||
for k, v in config.get_all().items():
|
||||
table.add_row(k, str(v))
|
||||
|
||||
console.print(table)
|
||||
|
||||
@config.command()
|
||||
@click.argument("key")
|
||||
def delete(key: str):
|
||||
"""Delete a configuration value."""
|
||||
config = Config()
|
||||
if key in config.get_all():
|
||||
config.delete(key)
|
||||
console.print(f"[green]Deleted {key}")
|
||||
else:
|
||||
console.print(f"[yellow]No value set for {key}")
|
||||
|
||||
@config.command()
|
||||
def clear():
|
||||
"""Clear all configuration values."""
|
||||
if click.confirm("Are you sure you want to clear all configuration?"):
|
||||
config = Config()
|
||||
config.clear()
|
||||
console.print("[green]Cleared all configuration")
|
||||
|
||||
# Add subcommands
|
||||
cli.add_command(gitignore_cli, name="gitignore")
|
||||
cli.add_command(commit_cli, name="commit")
|
||||
|
||||
if __name__ == "__main__":
|
||||
cli()
|
||||
Reference in new issue
Block a user