Phase 4: Shell completion scripts and comprehensive test suite

This commit is contained in:
truetype committed 2026-03-20 17:54:46 +01:00
1 parent aba2fc11f4
commit 5e70e22780
5 files changed
+641 -7

No files matched your search

+88
View File
@@ -0,0 +1,88 @@
#!/bin/bash
# Bash completion for MaxClaw Agent CLI
_maxclaw_completions()
{
local cur prev commands
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
# Main commands
commands="list search add remove set-active active test export import help"
# Handle main command completion
if [[ ${COMP_CWORD} -eq 1 ]]; then
COMPREPLY=( $(compgen -W "${commands}" -- ${cur}) )
return 0
fi
# Handle subcommand-specific completions
case "${prev}" in
search)
# Search term - no completion
return 0
;;
add)
# Add command options
local add_options="--non-interactive --name --provider --model --api-key --base-url --set-active"
COMPREPLY=( $(compgen -W "${add_options}" -- ${cur}) )
return 0
;;
remove|set-active|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)
# Provider options
local providers="openai ollama openrouter"
COMPREPLY=( $(compgen -W "${providers}" -- ${cur}) )
return 0
;;
--format)
# Format options
local formats="json yaml"
COMPREPLY=( $(compgen -W "${formats}" -- ${cur}) )
return 0
;;
esac
# Handle option arguments
case "${cur}" in
-*)
# Option completion
local options="--non-interactive --name --provider --model --api-key --base-url --set-active --format --output"
COMPREPLY=( $(compgen -W "${options}" -- ${cur}) )
return 0
;;
esac
return 0
}
complete -F _maxclaw_completions python3 config_cli.py
complete -F _maxclaw_completions python config_cli.py
+79
View File
@@ -0,0 +1,79 @@
#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 "$@"