From 4a323b899c7711a46fb1a7c745bbef4608a1ec0c Mon Sep 17 00:00:00 2001 From: Andrew Barnes Date: Fri, 29 May 2026 09:03:27 -0400 Subject: [PATCH] fix: improve skill.sh help and errors --- .gitattributes | 1 + skill.sh | 33 ++++++++++++++++++++++++++++----- 2 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..dfdb8b7 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.sh text eol=lf diff --git a/skill.sh b/skill.sh index 7f19ae7..0817b90 100644 --- a/skill.sh +++ b/skill.sh @@ -17,9 +17,32 @@ declare -A SKILLS=( [stitch-skill]="skills/stitch-skill/SKILL.md" ) -if [[ $# -eq 0 ]]; then - echo "Usage: source ./skill.sh " - echo "Available skills: ${!SKILLS[@]}" -else - echo "${SKILLS[$1]}" +print_help() { + echo "Usage: ./skill.sh " + echo " ./skill.sh --list" + echo + echo "Available skills:" + printf '%s\n' "${!SKILLS[@]}" | sort +} + +if [[ $# -eq 0 || "$1" == "-h" || "$1" == "--help" ]]; then + print_help + exit 0 +fi + +if [[ "$1" == "--list" ]]; then + printf '%s\n' "${!SKILLS[@]}" | sort + exit 0 fi + +skill_name="$1" +skill_path="${SKILLS[$skill_name]}" + +if [[ -z "$skill_path" ]]; then + echo "Unknown skill: $skill_name" >&2 + echo >&2 + print_help >&2 + exit 2 +fi + +echo "$skill_path"