#!/usr/bin/env bash
# Example helper script for skill template
#
# This script demonstrates the standard structure for skill helper scripts.
# Replace this with actual functionality for your skill.

set -euo pipefail

# Script directory (useful for referencing other skill files)
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SKILL_DIR="$(dirname "$SCRIPT_DIR")"

# Parse arguments
show_help() {
    cat << EOF
Usage: $(basename "$0") [OPTIONS] [ARGUMENTS]

Description of what this script does.

OPTIONS:
    -h, --help          Show this help message
    -v, --verbose       Enable verbose output
    -d, --dry-run       Show what would be done without doing it

ARGUMENTS:
    arg1               Description of argument 1
    arg2               Description of argument 2

EXAMPLES:
    $(basename "$0") value1 value2
    $(basename "$0") --verbose value1 value2
    $(basename "$0") --dry-run value1 value2

EOF
}

# Default values
VERBOSE=false
DRY_RUN=false

# Parse options
while [[ $# -gt 0 ]]; do
    case $1 in
        -h|--help)
            show_help
            exit 0
            ;;
        -v|--verbose)
            VERBOSE=true
            shift
            ;;
        -d|--dry-run)
            DRY_RUN=true
            shift
            ;;
        -*)
            echo "Error: Unknown option $1" >&2
            show_help
            exit 1
            ;;
        *)
            break
            ;;
    esac
done

# Validate arguments
if [[ $# -lt 1 ]]; then
    echo "Error: Missing required arguments" >&2
    show_help
    exit 1
fi

# Main logic
main() {
    local arg1="$1"
    local arg2="${2:-default}"
    
    if [[ "$VERBOSE" == "true" ]]; then
        echo "Running with arg1=$arg1, arg2=$arg2" >&2
    fi
    
    if [[ "$DRY_RUN" == "true" ]]; then
        echo "[DRY RUN] Would perform action with $arg1 and $arg2"
        exit 0
    fi
    
    # Actual work goes here
    echo "Result: Processed $arg1 with $arg2"
}

main "$@"
