Generate getopts-based argument parsing for shell scripts with short/long options and validation.
Generates getopts-based argument parsing code for shell scripts with short/long options and validation.
npx claudepluginhub a5c-ai/babysitterThis skill is limited to using the following tools:
README.mdGenerate getopts-based argument parsing for shell scripts.
Invoke this skill when you need to:
#!/usr/bin/env bash
# Default values
VERBOSE=false
OUTPUT=""
FORMAT="text"
FORCE=false
# Usage function
usage() {
cat <<EOF
Usage: $(basename "$0") [OPTIONS] <input>
Options:
-h, --help Show this help
-v, --verbose Enable verbose output
-o, --output FILE Output file (default: stdout)
-f, --format FORMAT Output format: text, json, csv (default: text)
-F, --force Force overwrite existing files
Arguments:
input Input file to process
EOF
}
# Parse options
parse_options() {
# Transform long options to short ones
for arg in "$@"; do
shift
case "$arg" in
'--help') set -- "$@" '-h' ;;
'--verbose') set -- "$@" '-v' ;;
'--output') set -- "$@" '-o' ;;
'--format') set -- "$@" '-f' ;;
'--force') set -- "$@" '-F' ;;
*) set -- "$@" "$arg" ;;
esac
done
# Parse short options
local OPTIND opt
while getopts ":hvo:f:F" opt; do
case "$opt" in
h) usage; exit 0 ;;
v) VERBOSE=true ;;
o) OUTPUT="$OPTARG" ;;
f)
case "$OPTARG" in
text|json|csv) FORMAT="$OPTARG" ;;
*) die "Invalid format: $OPTARG" ;;
esac
;;
F) FORCE=true ;;
:) die "Option -$OPTARG requires an argument" ;;
\?) die "Unknown option: -$OPTARG" ;;
esac
done
shift $((OPTIND - 1))
# Remaining arguments
if [[ $# -lt 1 ]]; then
usage
die "Missing required argument: input"
fi
INPUT="$1"
shift
# Extra arguments
EXTRA_ARGS=("$@")
}
die() {
echo "Error: $*" >&2
exit 1
}
# Parse and validate
parse_options "$@"
# Validation
[[ -f "$INPUT" ]] || die "Input file not found: $INPUT"
[[ -n "$OUTPUT" && -f "$OUTPUT" && "$FORCE" != true ]] && \
die "Output file exists: $OUTPUT (use --force to overwrite)"
Activates when the user asks about AI prompts, needs prompt templates, wants to search for prompts, or mentions prompts.chat. Use for discovering, retrieving, and improving prompts.
Search, retrieve, and install Agent Skills from the prompts.chat registry using MCP tools. Use when the user asks to find skills, browse skill catalogs, install a skill for Claude, or extend Claude's capabilities with reusable AI agent components.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.