- Rewrote langcode.bash with full unified CLI support - Rewrote langcode.zsh with full unified CLI support - All commands: chat, server, tui, config, analytics, dashboard, version - Config subcommands: list, add, remove, use, active, test, export, import, search
108 lines
4.0 KiB
Bash
108 lines
4.0 KiB
Bash
#compdef langcode
|
|
# Zsh completion for LangCode Agent CLI
|
|
|
|
_langcode() {
|
|
local -a commands config_subcommands
|
|
local curcontext="$curcontext" state line
|
|
typeset -A opt_args
|
|
|
|
_arguments -C \
|
|
'1: :->command' \
|
|
'*::arg:->args'
|
|
|
|
case $state in
|
|
command)
|
|
commands=(
|
|
'chat:Avvia l'\''agent in modalità chat'
|
|
'server:Avvia il web server'
|
|
'tui:Apre TUI per gestione configurazioni'
|
|
'config:Gestione configurazioni'
|
|
'analytics:Mostra analytics'
|
|
'dashboard:Mostra dashboard performance'
|
|
'version:Mostra versione'
|
|
)
|
|
_describe -t commands 'LangCode commands' commands
|
|
;;
|
|
args)
|
|
case ${line[1]} in
|
|
config)
|
|
config_subcommands=(
|
|
'list:Lista configurazioni'
|
|
'add:Aggiungi configurazione'
|
|
'remove:Rimuovi configurazione'
|
|
'use:Attiva configurazione'
|
|
'active:Mostra configurazione attiva'
|
|
'test:Testa connessione configurazione'
|
|
'export:Esporta configurazioni'
|
|
'import:Importa configurazioni'
|
|
'search:Cerca configurazioni'
|
|
)
|
|
_describe -t config_commands 'config commands' config_subcommands
|
|
;;
|
|
server)
|
|
_arguments \
|
|
'--port[Porta del server]:port:(8000 3000 8080 5000)' \
|
|
'--host[Host del server]:host'
|
|
;;
|
|
analytics)
|
|
_arguments \
|
|
'--report[Genera report completo]' \
|
|
'--clear[Cancella dati analytics]'
|
|
;;
|
|
dashboard)
|
|
_arguments \
|
|
'--clear[Cancella dati performance]'
|
|
;;
|
|
config)
|
|
case ${line[2]} in
|
|
search)
|
|
_message 'termine di ricerca'
|
|
;;
|
|
add)
|
|
_arguments \
|
|
'--name[Nome configurazione]:name' \
|
|
'--provider[Provider]:provider:(openai ollama openrouter anthropic google)' \
|
|
'--model[Modello]:model' \
|
|
'--api-key[API key]:api_key' \
|
|
'--base-url[Base URL]:base_url' \
|
|
'--activate[Attiva dopo la creazione]'
|
|
;;
|
|
remove|use|test)
|
|
# Try to get configuration names
|
|
local -a configs
|
|
if (( $+commands[python3] )); then
|
|
configs=(${(f)"$(python3 -c "
|
|
import sys
|
|
sys.path.insert(0, '.')
|
|
try:
|
|
from config_manager import config_manager
|
|
configs = config_manager.list_configuration_names()
|
|
for c in configs:
|
|
print(c)
|
|
except:
|
|
pass
|
|
" 2>/dev/null)"})
|
|
fi
|
|
if (( ${#configs} )); then
|
|
_describe -t configurations 'configurazioni' configs
|
|
else
|
|
_message 'nome configurazione'
|
|
fi
|
|
;;
|
|
export)
|
|
_arguments \
|
|
'--format[Formato export]:format:(json yaml)' \
|
|
'--output[File output]:filename'
|
|
;;
|
|
import)
|
|
_files -g '*.json *.yaml *.yml'
|
|
;;
|
|
esac
|
|
;;
|
|
esac
|
|
;;
|
|
esac
|
|
}
|
|
|
|
_langcode "$@"
|