#!/usr/bin/env bash # Output getoptlong.sh initialization script # Usage: eval "$(getoptlong OPTS)" script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" if [[ $# -eq 0 ]]; then echo "Usage: eval \"\$(getoptlong OPTS)\"" >&2 set -- OPTS exit_code=1 fi cat < declare -A OPTS=( [ &USAGE ]="command [options] file..." [ flag | f # Flag ]= [ counter | c + # Counter ]=0 [ required | r : # Required ]=/dev/stdout [ optional | o ? # Optional ]= [ verbose | v | ~q # Deny ]= [ array | A @ # Array ]= [ hash | H % # Hash ]= [ integer | i :=i # Integer ]=1 [ pattern | p :=(^(fast|slow)$) # Regex ]=fast ) B . getoptlong.sh OPTS "$@" B . getoptlong.sh - getoptlong init OPTS getoptlong parse "$@" && eval "$(getoptlong set)" B eval "$(getoptlong OPTS)" =head1 VERSION 1.0.0 =head1 DESCRIPTION B is a Bash library providing Perl's L-style option parsing. Options are defined in a Bash associative array: the key specifies the option name, aliases, type, and other attributes; the value sets the default. The library parses command-line arguments, sets variables, and leaves non-option arguments in C<$@>. Two usage modes are available: B for simple scripts (source with array name and arguments), and B for advanced control (separate init, parse, and set calls). Supports short (C<-v>) and long (C<--verbose>) options with bundling (C<-vvv>). B