Files

88 lines
2.5 KiB
Bash

#!/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