- 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
131 lines
4.1 KiB
Bash
131 lines
4.1 KiB
Bash
#!/bin/bash
|
|
# Bash completion for LangCode Agent CLI
|
|
|
|
_langcode_completions()
|
|
{
|
|
local cur prev commands subcommands
|
|
COMPREPLY=()
|
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
|
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
|
|
|
# Main commands
|
|
commands="chat server tui config analytics dashboard version"
|
|
|
|
# Config subcommands
|
|
config_subcommands="list add remove use active test export import search"
|
|
|
|
# Handle main command completion
|
|
if [[ ${COMP_CWORD} -eq 1 ]]; then
|
|
COMPREPLY=( $(compgen -W "${commands}" -- ${cur}) )
|
|
return 0
|
|
fi
|
|
|
|
# Handle config subcommand completion
|
|
if [[ "${COMP_WORDS[1]}" == "config" && ${COMP_CWORD} -eq 2 ]]; then
|
|
COMPREPLY=( $(compgen -W "${config_subcommands}" -- ${cur}) )
|
|
return 0
|
|
fi
|
|
|
|
# Handle subcommand-specific completions
|
|
case "${prev}" in
|
|
server)
|
|
local server_options="--port --host"
|
|
COMPREPLY=( $(compgen -W "${server_options}" -- ${cur}) )
|
|
return 0
|
|
;;
|
|
analytics)
|
|
local analytics_options="--report --clear"
|
|
COMPREPLY=( $(compgen -W "${analytics_options}" -- ${cur}) )
|
|
return 0
|
|
;;
|
|
dashboard)
|
|
local dashboard_options="--clear"
|
|
COMPREPLY=( $(compgen -W "${dashboard_options}" -- ${cur}) )
|
|
return 0
|
|
;;
|
|
search)
|
|
# Search term - no completion
|
|
return 0
|
|
;;
|
|
add)
|
|
# Add command options
|
|
local add_options="--name --provider --model --api-key --base-url --activate"
|
|
COMPREPLY=( $(compgen -W "${add_options}" -- ${cur}) )
|
|
return 0
|
|
;;
|
|
remove|use|test)
|
|
# Configuration names - try to get from config list
|
|
if command -v python3 &> /dev/null; then
|
|
local configs=$(python3 -c "
|
|
import sys
|
|
sys.path.insert(0, '.')
|
|
try:
|
|
from config_manager import config_manager
|
|
configs = config_manager.list_configuration_names()
|
|
print(' '.join(configs))
|
|
except:
|
|
pass
|
|
" 2>/dev/null)
|
|
COMPREPLY=( $(compgen -W "${configs}" -- ${cur}) )
|
|
fi
|
|
return 0
|
|
;;
|
|
export)
|
|
# Export options
|
|
local export_options="--format --output"
|
|
COMPREPLY=( $(compgen -W "${export_options}" -- ${cur}) )
|
|
return 0
|
|
;;
|
|
import)
|
|
# File completion
|
|
COMPREPLY=( $(compgen -f -- ${cur}) )
|
|
return 0
|
|
;;
|
|
--provider|-p)
|
|
# Provider options
|
|
local providers="openai ollama openrouter anthropic google"
|
|
COMPREPLY=( $(compgen -W "${providers}" -- ${cur}) )
|
|
return 0
|
|
;;
|
|
--format|-f)
|
|
# Format options
|
|
local formats="json yaml"
|
|
COMPREPLY=( $(compgen -W "${formats}" -- ${cur}) )
|
|
return 0
|
|
;;
|
|
--port|-p)
|
|
# Port suggestions
|
|
local ports="8000 3000 8080 5000"
|
|
COMPREPLY=( $(compgen -W "${ports}" -- ${cur}) )
|
|
return 0
|
|
;;
|
|
esac
|
|
|
|
# Handle option arguments
|
|
case "${cur}" in
|
|
-*)
|
|
# Option completion based on context
|
|
if [[ "${COMP_WORDS[1]}" == "server" ]]; then
|
|
local options="--port --host"
|
|
elif [[ "${COMP_WORDS[1]}" == "config" && "${COMP_WORDS[2]}" == "add" ]]; then
|
|
local options="--name --provider --model --api-key --base-url --activate"
|
|
elif [[ "${COMP_WORDS[1]}" == "config" && "${COMP_WORDS[2]}" == "export" ]]; then
|
|
local options="--format --output"
|
|
elif [[ "${COMP_WORDS[1]}" == "analytics" ]]; then
|
|
local options="--report --clear"
|
|
elif [[ "${COMP_WORDS[1]}" == "dashboard" ]]; then
|
|
local options="--clear"
|
|
else
|
|
local options="--help --version"
|
|
fi
|
|
COMPREPLY=( $(compgen -W "${options}" -- ${cur}) )
|
|
return 0
|
|
;;
|
|
esac
|
|
|
|
return 0
|
|
}
|
|
|
|
complete -F _langcode_completions langcode
|
|
complete -F _langcode_completions langcode.py
|