mirror of
https://github.com/tiennm99/ccs.git
synced 2026-07-16 18:16:08 +00:00
Implements 6-phase CLI UX improvement plan with comprehensive error handling, interactive features, and cross-platform consistency. ### Added - Shell auto-completion (bash, zsh, PowerShell, Fish) - Error codes (E101-E901) with documentation URLs - Fuzzy matching "Did you mean?" suggestions (Levenshtein distance) - Progress indicators (doctor [n/9] counter, GLMT proxy spinner) - Interactive confirmation prompts with --yes/-y automation flag - JSON output format (--json) for auth commands - Impact display (session count, paths) before destructive operations - Comprehensive test suite (15 tests, 100% pass rate) - Complete error documentation in docs/errors/ - Cross-platform `--shell-completion` command ### Changed - Error boxes: Unicode (╔═╗) → ASCII (===) for compatibility - JSON output uses CCS version instead of schema version - Help text includes EXAMPLES section across platforms - Test suite properly counts test cases (not assertions) ### Fixed - --yes flag bug (returned false instead of true) - Help text consistency (added Uninstall section to bash) - Test pass rate calculation (excludes skipped tests) - Help section comparison (locale-specific sort) ### Testing - 13/13 tests passing (2 legitimately skipped) - Cross-platform verified (Node.js, bash, PowerShell) - All error codes documented and tested
82 lines
2.3 KiB
Bash
82 lines
2.3 KiB
Bash
# Bash completion for CCS (Claude Code Switch)
|
|
# Compatible with bash 3.2+
|
|
#
|
|
# Installation:
|
|
# Add to ~/.bashrc or ~/.bash_profile:
|
|
# source /path/to/ccs/scripts/completion/ccs.bash
|
|
#
|
|
# Or install system-wide (requires sudo):
|
|
# sudo cp scripts/completion/ccs.bash /etc/bash_completion.d/ccs
|
|
|
|
_ccs_completion() {
|
|
local cur prev words cword
|
|
COMPREPLY=()
|
|
|
|
# Get current word and previous word
|
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
|
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
|
|
|
# Top-level completion (first argument)
|
|
if [[ ${COMP_CWORD} -eq 1 ]]; then
|
|
local commands="auth doctor"
|
|
local flags="--help --version -h -v"
|
|
local profiles=""
|
|
|
|
# Add profiles from config.json (settings-based profiles)
|
|
if [[ -f ~/.ccs/config.json ]]; then
|
|
profiles="$profiles $(jq -r '.profiles | keys[]' ~/.ccs/config.json 2>/dev/null || true)"
|
|
fi
|
|
|
|
# Add profiles from profiles.json (account-based profiles)
|
|
if [[ -f ~/.ccs/profiles.json ]]; then
|
|
profiles="$profiles $(jq -r '.profiles | keys[]' ~/.ccs/profiles.json 2>/dev/null || true)"
|
|
fi
|
|
|
|
# Combine all options
|
|
local opts="$commands $flags $profiles"
|
|
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
|
return 0
|
|
fi
|
|
|
|
# auth subcommands
|
|
if [[ ${prev} == "auth" ]]; then
|
|
local auth_commands="create list show remove default --help -h"
|
|
COMPREPLY=( $(compgen -W "${auth_commands}" -- ${cur}) )
|
|
return 0
|
|
fi
|
|
|
|
# Completion for auth subcommands that need profile names
|
|
if [[ ${COMP_WORDS[1]} == "auth" ]]; then
|
|
case "${prev}" in
|
|
show|remove|default)
|
|
# Complete with account profile names only
|
|
if [[ -f ~/.ccs/profiles.json ]]; then
|
|
local profiles=$(jq -r '.profiles | keys[]' ~/.ccs/profiles.json 2>/dev/null || true)
|
|
COMPREPLY=( $(compgen -W "${profiles}" -- ${cur}) )
|
|
fi
|
|
return 0
|
|
;;
|
|
create)
|
|
# No completion for create (user enters new name)
|
|
return 0
|
|
;;
|
|
list)
|
|
# Complete with list flags
|
|
COMPREPLY=( $(compgen -W "--verbose --json" -- ${cur}) )
|
|
return 0
|
|
;;
|
|
esac
|
|
fi
|
|
|
|
# Flags for doctor command
|
|
if [[ ${COMP_WORDS[1]} == "doctor" ]]; then
|
|
COMPREPLY=( $(compgen -W "--help -h" -- ${cur}) )
|
|
return 0
|
|
fi
|
|
|
|
return 0
|
|
}
|
|
|
|
# Register completion function
|
|
complete -F _ccs_completion ccs
|