Skip to content
cccskills
FreePublished on GitHub

getopts-parser-generator

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

The English summary is being prepared. Showing the original description.

See how to install

Files included (2)

  • SKILL.md3.1 KB
  • README.md757 B

SKILL.md (original)

Review the instructions the agent will receive before you install.

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

#!/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)"

Target Processes

  • shell-script-development
  • shell-completion-scripts
  • argument-parser-setup

Reviews

No reviews yet. Tell others what you thought.

Comments

No login needed. Share how it worked for you, ask a question, or note where it did not run.

No comments yet. Be the first to write one.

Comments are published right away. Do not include personal information such as email addresses or phone numbers. Up to 2 URLs.

0 / 1,000 characters

This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.

More skills from this repository

Provide implementations of advanced data structures

The English summary is being prepared. Showing the original description.

a5c-ai/babysitter1.9KUpdated Sep 17, 2026

Fresh adversarial code review with binary PASS/FAIL verdicts, evidence citations, and anchoring bias prevention via fresh reviewer spawning.

The English summary is being prepared. Showing the original description.

a5c-ai/babysitter1.9KUpdated Sep 17, 2026

WASM-based instant code transforms for simple tasks, achieving 352x speedup over LLM inference with zero cost.

The English summary is being prepared. Showing the original description.

a5c-ai/babysitter1.9KUpdated Sep 17, 2026

Coordinate Crew (persistent) and Polecat (transient) agents using Gas Town's hook-based work distribution and GUPP principle.

The English summary is being prepared. Showing the original description.

a5c-ai/babysitter1.9KUpdated Sep 17, 2026

Generate visual representations of algorithm execution

The English summary is being prepared. Showing the original description.

a5c-ai/babysitter1.9KUpdated Sep 17, 2026

Hierarchical coordination and drift detection with frequent checkpoints, shared memory coherence validation, role specialization enforcement, and short task cycles.

The English summary is being prepared. Showing the original description.

a5c-ai/babysitter1.9KUpdated Sep 17, 2026

See all skills by a5c-ai

Report a problem with this skill