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"
|
UNIFIED_ENV="${GLOBAL_DIR}/.env"
|
||||||
REPO_UNIFIED_ENV="${REPO_ROOT}/.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
|
# Colors
|
||||||
INFO='\033[0;34m'
|
INFO='\033[0;34m'
|
||||||
SUCCESS='\033[0;32m'
|
SUCCESS='\033[0;32m'
|
||||||
@@ -32,6 +60,8 @@ get_skills() {
|
|||||||
for dir in "$SKILLS_DIR"/*/; do
|
for dir in "$SKILLS_DIR"/*/; do
|
||||||
[ -d "$dir" ] || continue
|
[ -d "$dir" ] || continue
|
||||||
name=$(basename "$dir")
|
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"
|
[ -f "$dir/SKILL.md" ] && found="$found $name"
|
||||||
done
|
done
|
||||||
echo $found
|
echo $found
|
||||||
@@ -212,18 +242,12 @@ main() {
|
|||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
# Choose install location
|
# Choose install location
|
||||||
line
|
if [ $INSTALL_GLOBAL -eq 1 ]; then
|
||||||
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
|
|
||||||
TARGET="$GLOBAL_SKILLS_DIR"
|
TARGET="$GLOBAL_SKILLS_DIR"
|
||||||
|
print_info "Installing to global: $TARGET"
|
||||||
|
else
|
||||||
|
TARGET="${REPO_ROOT}/.opencode/skills"
|
||||||
|
print_info "Installing to project: $TARGET"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mkdir -p "$TARGET"
|
mkdir -p "$TARGET"
|
||||||
@@ -236,12 +260,17 @@ main() {
|
|||||||
dest="${TARGET}/${skill}"
|
dest="${TARGET}/${skill}"
|
||||||
|
|
||||||
if [ -d "$dest" ]; then
|
if [ -d "$dest" ]; then
|
||||||
|
if [ $FORCE -eq 0 ] && [ $AUTO_YES -eq 0 ]; then
|
||||||
echo -n "$skill exists. Overwrite? [y/N]: "
|
echo -n "$skill exists. Overwrite? [y/N]: "
|
||||||
read ow
|
read ow
|
||||||
if [ "$ow" != "y" ] && [ "$ow" != "Y" ]; then
|
if [ "$ow" != "y" ] && [ "$ow" != "Y" ]; then
|
||||||
print_warning "Skipped $skill"
|
print_warning "Skipped $skill"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
elif [ $AUTO_YES -eq 1 ]; then
|
||||||
|
print_info "Skipping $skill (existing)"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
rm -rf "$dest"
|
rm -rf "$dest"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user