From 861467e307580501713edb2ce6ef349d32efdb73 Mon Sep 17 00:00:00 2001 From: kaitranntt Date: Sun, 2 Nov 2025 13:47:10 -0500 Subject: [PATCH] feat(cli): add --help and version support (v1.1.0) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add version command: ccs --version, ccs version, ccs -v - Add help forwarding: ccs --help, ccs -h, ccs help → forwards to Claude CLI - Fix W1 warning: ccs --help no longer treats --help as profile name - Consistent implementation across bash and PowerShell - Update README (EN/VI) with utility commands documentation Features: - Version constant: CCS_VERSION = "1.1.0" - Early return pattern for meta-commands (work without config) - Help commands forward to Claude CLI --help - Version commands show CCS version + GitHub URL Testing: - All 9 tests passed (100%) - No regressions in existing functionality - Verified on Windows PowerShell 5.1 Resolves: W1 warning from comprehensive testing Tested-by: QA Agent Reviewed-by: Code Review Agent --- README.md | 10 +++++++--- README.vi.md | 10 +++++++--- ccs | 16 ++++++++++++++++ ccs.ps1 | 26 ++++++++++++++++++++++++++ 4 files changed, 56 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 0970f5d7..2923461b 100644 --- a/README.md +++ b/README.md @@ -54,9 +54,13 @@ EOF **Use**: ```bash -ccs # Use default profile -ccs glm # Use GLM profile -ccs son # Use Sonnet profile +ccs # Use default profile +ccs glm # Use GLM profile +ccs son # Use Sonnet profile + +# Utility commands +ccs --version # Show CCS version +ccs --help # Show Claude CLI help ``` ## Why CCS? diff --git a/README.vi.md b/README.vi.md index e8c1daab..6352c0e2 100644 --- a/README.vi.md +++ b/README.vi.md @@ -54,9 +54,13 @@ EOF **Sử dụng**: ```bash -ccs # Dùng profile mặc định -ccs glm # Dùng GLM profile -ccs son # Dùng Sonnet profile +ccs # Dùng profile mặc định +ccs glm # Dùng GLM profile +ccs son # Dùng Sonnet profile + +# Lệnh tiện ích +ccs --version # Hiển thị phiên bản CCS +ccs --help # Hiển thị trợ giúp Claude CLI ``` ## Tại Sao Nên Dùng CCS? diff --git a/ccs b/ccs index 7bf5bd6b..4b5c0fef 100755 --- a/ccs +++ b/ccs @@ -1,9 +1,25 @@ #!/usr/bin/env bash set -euo pipefail +# Version +CCS_VERSION="1.1.0" + CONFIG_FILE="${CCS_CONFIG:-$HOME/.ccs/config.json}" PROFILE="${1:-default}" +# Special case: version command +if [[ "$PROFILE" == "version" || "$PROFILE" == "--version" || "$PROFILE" == "-v" ]]; then + echo "CCS (Claude Code Switch) version $CCS_VERSION" + echo "https://github.com/kaitranntt/ccs" + exit 0 +fi + +# Special case: help command (forward to Claude CLI) +if [[ "$PROFILE" == "--help" || "$PROFILE" == "-h" || "$PROFILE" == "help" ]]; then + shift # Remove the help argument + exec claude --help "$@" +fi + # Check config exists if [[ ! -f "$CONFIG_FILE" ]]; then echo "Error: Config file not found: $CONFIG_FILE" diff --git a/ccs.ps1 b/ccs.ps1 index 52112ab6..9289b820 100644 --- a/ccs.ps1 +++ b/ccs.ps1 @@ -12,6 +12,32 @@ param( $ErrorActionPreference = "Stop" +# Version +$CCS_VERSION = "1.1.0" + +# Special case: version command +if ($Profile -eq "version" -or $Profile -eq "--version" -or $Profile -eq "-v") { + Write-Host "CCS (Claude Code Switch) version $CCS_VERSION" + Write-Host "https://github.com/kaitranntt/ccs" + exit 0 +} + +# Special case: help command (forward to Claude CLI) +if ($Profile -eq "--help" -or $Profile -eq "-h" -or $Profile -eq "help") { + try { + if ($RemainingArgs) { + & claude --help @RemainingArgs + } else { + & claude --help + } + exit $LASTEXITCODE + } catch { + Write-Host "Error: Failed to execute claude --help" -ForegroundColor Red + Write-Host $_.Exception.Message + exit 1 + } +} + # Special case: "default" profile just runs claude directly (no profile switching) if ($Profile -eq "default") { try {