mirror of
https://github.com/GuDaStudio/commands.git
synced 2026-03-22 19:18:52 +08:00
v0.0:初始版本
This commit is contained in:
109
install.sh
Normal file
109
install.sh
Normal file
@@ -0,0 +1,109 @@
|
||||
#!/bin/bash
|
||||
# GudaCC Commands Installer
|
||||
# https://github.com/GuDaStudio/commands
|
||||
|
||||
set -e
|
||||
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m'
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
COMMAND_NAME="gudaspec"
|
||||
|
||||
usage() {
|
||||
echo -e "${BLUE}GudaCC Commands Installer${NC}"
|
||||
echo ""
|
||||
echo "Usage: $0 [OPTIONS]"
|
||||
echo ""
|
||||
echo "Options:"
|
||||
echo " -u, --user Install to user-level (~/.claude/commands/)"
|
||||
echo " -p, --project Install to project-level (./.claude/commands/)"
|
||||
echo " -t, --target <path> Install to custom target path"
|
||||
echo " -h, --help Show this help message"
|
||||
echo ""
|
||||
echo "Examples:"
|
||||
echo " $0 --user"
|
||||
echo " $0 --project"
|
||||
echo " $0 --target /custom/path"
|
||||
}
|
||||
|
||||
install_command() {
|
||||
local target_dir=$1
|
||||
local source_dir="$SCRIPT_DIR/$COMMAND_NAME"
|
||||
local dest_dir="$target_dir/$COMMAND_NAME"
|
||||
|
||||
if [ ! -d "$source_dir" ]; then
|
||||
echo -e "${RED}Error: '$COMMAND_NAME' not found in source directory${NC}"
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo -e "${BLUE}Installing${NC} $COMMAND_NAME -> $dest_dir"
|
||||
|
||||
mkdir -p "$target_dir"
|
||||
|
||||
if [ -d "$dest_dir" ]; then
|
||||
echo -e "${YELLOW} Removing existing installation...${NC}"
|
||||
rm -rf "$dest_dir"
|
||||
fi
|
||||
|
||||
cp -r "$source_dir" "$dest_dir"
|
||||
|
||||
if [ -f "$dest_dir/.git" ]; then
|
||||
rm "$dest_dir/.git"
|
||||
fi
|
||||
|
||||
echo -e "${GREEN} ✓ Installed${NC}"
|
||||
}
|
||||
|
||||
TARGET_PATH=""
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
-u|--user)
|
||||
TARGET_PATH="$HOME/.claude/commands"
|
||||
shift
|
||||
;;
|
||||
-p|--project)
|
||||
TARGET_PATH="./.claude/commands"
|
||||
shift
|
||||
;;
|
||||
-t|--target)
|
||||
TARGET_PATH="$2"
|
||||
shift 2
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo -e "${RED}Unknown option: $1${NC}"
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ -z "$TARGET_PATH" ]; then
|
||||
echo -e "${RED}Error: Please specify installation target (-u, -p, or -t)${NC}"
|
||||
echo ""
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
|
||||
echo -e "${BLUE}GudaCC Commands Installer${NC}"
|
||||
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
|
||||
echo ""
|
||||
echo -e "Target: ${GREEN}$TARGET_PATH${NC}"
|
||||
echo -e "Command: ${GREEN}$COMMAND_NAME${NC}"
|
||||
echo ""
|
||||
|
||||
install_command "$TARGET_PATH"
|
||||
|
||||
echo ""
|
||||
echo -e "${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
|
||||
echo -e "${GREEN}Installation complete!${NC}"
|
||||
echo -e "${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
|
||||
Reference in New Issue
Block a user