feat: update install-skills.sh with --force --yes flags for non-interactive use
- Add -f/--force flag to overwrite existing skills without prompting - Add -y/--yes flag to skip all existing skills - Add -g/--global and -p/--project flags for install location - Skip embedded git repos (cloned external skills) when detecting skills - Remove interactive prompts in favor of flags
This commit is contained in:
@@ -13,6 +13,34 @@ GLOBAL_SKILLS_DIR="${GLOBAL_DIR}/skills"
|
||||
UNIFIED_ENV="${GLOBAL_DIR}/.env"
|
||||
REPO_UNIFIED_ENV="${REPO_ROOT}/.env"
|
||||
|
||||
# Args
|
||||
FORCE=0
|
||||
AUTO_YES=0
|
||||
INSTALL_GLOBAL=1
|
||||
|
||||
usage() {
|
||||
echo "Usage: $0 [OPTIONS]"
|
||||
echo ""
|
||||
echo "Options:"
|
||||
echo " -f, --force Overwrite existing skills without prompting"
|
||||
echo " -y, --yes Answer yes to all prompts"
|
||||
echo " -g, --global Install to global ~/.config/opencode/skills (default)"
|
||||
echo " -p, --project Install to project .opencode/skills"
|
||||
echo " -h, --help Show this help message"
|
||||
exit 0
|
||||
}
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
-f|--force) FORCE=1; shift ;;
|
||||
-y|--yes) AUTO_YES=1; shift ;;
|
||||
-g|--global) INSTALL_GLOBAL=1; shift ;;
|
||||
-p|--project) INSTALL_GLOBAL=0; shift ;;
|
||||
-h|--help) usage ;;
|
||||
*) shift ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Colors
|
||||
INFO='\033[0;34m'
|
||||
SUCCESS='\033[0;32m'
|
||||
@@ -32,6 +60,8 @@ get_skills() {
|
||||
for dir in "$SKILLS_DIR"/*/; do
|
||||
[ -d "$dir" ] || continue
|
||||
name=$(basename "$dir")
|
||||
# Skip if it's an embedded git repo (like cloned external skills)
|
||||
[ -d "$dir/.git" ] && continue
|
||||
[ -f "$dir/SKILL.md" ] && found="$found $name"
|
||||
done
|
||||
echo $found
|
||||
@@ -212,18 +242,12 @@ main() {
|
||||
echo ""
|
||||
|
||||
# Choose install location
|
||||
line
|
||||
print_info "Install location:"
|
||||
echo " 1) Global (~/.config/opencode/skills)"
|
||||
echo " 2) Project (./.opencode/skills)"
|
||||
line
|
||||
echo -n "Choice [1]: "
|
||||
read choice
|
||||
|
||||
if [ "$choice" = "2" ]; then
|
||||
TARGET="${REPO_ROOT}/.opencode/skills"
|
||||
else
|
||||
if [ $INSTALL_GLOBAL -eq 1 ]; then
|
||||
TARGET="$GLOBAL_SKILLS_DIR"
|
||||
print_info "Installing to global: $TARGET"
|
||||
else
|
||||
TARGET="${REPO_ROOT}/.opencode/skills"
|
||||
print_info "Installing to project: $TARGET"
|
||||
fi
|
||||
|
||||
mkdir -p "$TARGET"
|
||||
@@ -236,10 +260,15 @@ main() {
|
||||
dest="${TARGET}/${skill}"
|
||||
|
||||
if [ -d "$dest" ]; then
|
||||
echo -n "$skill exists. Overwrite? [y/N]: "
|
||||
read ow
|
||||
if [ "$ow" != "y" ] && [ "$ow" != "Y" ]; then
|
||||
print_warning "Skipped $skill"
|
||||
if [ $FORCE -eq 0 ] && [ $AUTO_YES -eq 0 ]; then
|
||||
echo -n "$skill exists. Overwrite? [y/N]: "
|
||||
read ow
|
||||
if [ "$ow" != "y" ] && [ "$ow" != "Y" ]; then
|
||||
print_warning "Skipped $skill"
|
||||
continue
|
||||
fi
|
||||
elif [ $AUTO_YES -eq 1 ]; then
|
||||
print_info "Skipping $skill (existing)"
|
||||
continue
|
||||
fi
|
||||
rm -rf "$dest"
|
||||
|
||||
Reference in New Issue
Block a user