getopts-parser-generator

Solid

Generate getopts-based argument parsing for shell scripts with short/long options and validation.

AI & Automation 814 stars 53 forks Updated today MIT

Install

View on GitHub

Quality Score: 95/100

Stars 20%
97
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Getopts Parser Generator Generate getopts-based argument parsing for shell scripts. ## Capabilities - Generate getopts parsing code - Support short and long options - Implement option validation - Create help text generation - Handle required arguments - Generate usage documentation ## Usage Invoke this skill when you need to: - Add argument parsing to shell scripts - Support short and long options - Validate argument values - Generate help text ## Generated Patterns ### Getopts with Long Options ```bash #!/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...

Details

Author
a5c-ai
Repository
a5c-ai/babysitter
Created
4 months ago
Last Updated
today
Language
JavaScript
License
MIT

Related Skills