79 lines
2.6 KiB
Bash
79 lines
2.6 KiB
Bash
#compdef config_cli.py
|
|
# Zsh completion for MaxClaw Agent CLI
|
|
|
|
_maxclaw() {
|
|
local -a commands
|
|
local curcontext="$curcontext" state line
|
|
typeset -A opt_args
|
|
|
|
_arguments -C \
|
|
'1: :->command' \
|
|
'*::arg:->args'
|
|
|
|
case $state in
|
|
command)
|
|
commands=(
|
|
'list:List all configurations'
|
|
'search:Search configurations'
|
|
'add:Add a new configuration'
|
|
'remove:Remove a configuration'
|
|
'set-active:Set active configuration'
|
|
'active:Show active configuration'
|
|
'test:Test connection to a configuration'
|
|
'export:Export configurations to JSON/YAML'
|
|
'import:Import configurations from JSON/YAML'
|
|
'help:Show help'
|
|
)
|
|
_describe -t commands 'MaxClaw commands' commands
|
|
;;
|
|
args)
|
|
case ${line[1]} in
|
|
search)
|
|
_message 'search term'
|
|
;;
|
|
add)
|
|
_arguments \
|
|
'--non-interactive[Non-interactive mode]' \
|
|
'--name[Configuration name]:name' \
|
|
'--provider[Provider]:provider:(openai ollama openrouter)' \
|
|
'--model[Model name]:model' \
|
|
'--api-key[API key]:api_key' \
|
|
'--base-url[Base URL]:base_url' \
|
|
'--set-active[Set as active configuration]'
|
|
;;
|
|
remove|set-active|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 'configurations' configs
|
|
else
|
|
_message 'configuration name'
|
|
fi
|
|
;;
|
|
export)
|
|
_arguments \
|
|
'--format[Export format]:format:(json yaml)' \
|
|
'--output[Output filename]:filename'
|
|
;;
|
|
import)
|
|
_files -g '*.json *.yaml *.yml'
|
|
;;
|
|
esac
|
|
;;
|
|
esac
|
|
}
|
|
|
|
_maxclaw "$@" |