feat(shell-completion): add --force flag and fix zsh profile coloring

This commit is contained in:
kaitranntt
2025-12-01 17:54:41 -05:00
parent 53d7a15c04
commit 7faed1d84b
6 changed files with 239 additions and 29 deletions
+31 -1
View File
@@ -18,7 +18,7 @@ _ccs_completion() {
# Top-level completion (first argument)
if [[ ${COMP_CWORD} -eq 1 ]]; then
local commands="auth doctor sync update"
local commands="auth profile doctor sync update"
local flags="--help --version --shell-completion -h -v -sc"
local profiles=""
@@ -45,6 +45,36 @@ _ccs_completion() {
return 0
fi
# profile subcommands
if [[ ${prev} == "profile" ]]; then
local profile_commands="create list remove --help -h"
COMPREPLY=( $(compgen -W "${profile_commands}" -- ${cur}) )
return 0
fi
# Completion for profile subcommands
if [[ ${COMP_WORDS[1]} == "profile" ]]; then
case "${prev}" in
remove|delete|rm)
# Complete with settings profile names
if [[ -f ~/.ccs/config.json ]]; then
local profiles=$(jq -r '.profiles | keys[]' ~/.ccs/config.json 2>/dev/null || true)
COMPREPLY=( $(compgen -W "${profiles}" -- ${cur}) )
fi
return 0
;;
create)
# Complete with create flags
COMPREPLY=( $(compgen -W "--base-url --api-key --model --force --yes -y" -- ${cur}) )
return 0
;;
list)
# No flags for list
return 0
;;
esac
fi
# Completion for auth subcommands that need profile names
if [[ ${COMP_WORDS[1]} == "auth" ]]; then
case "${prev}" in