An elegant option parser for shell scripts with full support for all POSIX shells.
getoptions is an elegant option parser and generator for shell scripts, designed to handle command-line arguments with full support for all POSIX shells. It solves the problem of parsing complex options in shell scripts by providing a DSL-like definition syntax, automatic help generation, and support for both POSIX and GNU-style argument syntax without relying on external commands like `getopt`.
Shell script developers who need robust, portable command-line argument parsing for utilities, tools, or distributed scripts across different POSIX-compliant environments.
Developers choose getoptions for its portability, simplicity, and comprehensive feature set—it eliminates the limitations of traditional `getopt`/`getopts`, supports long options and subcommands, and offers multiple integration modes (command, library, or generator) for flexibility and performance.
An elegant option/argument parser for shell scripts (full support for bash and all POSIX shells)
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Works with all POSIX shells like bash, dash, ksh, and zsh without bashisms, ensuring broad portability across Unix-like systems, as highlighted in the features list.
Offers three usage methods: as a command for ease, a library for distribution, and a generator for optimal performance, allowing developers to balance convenience and speed based on needs.
Generates help text automatically from parser definitions, reducing manual documentation effort and ensuring consistency, as demonstrated in the TL;DR example.
Enables parsing of complex CLI structures with subcommands and includes features like pattern matching validation, making it suitable for robust utility development.
The README documents breaking changes in 2.x and 3.x releases, such as renamed attributes and functions, which can require migration effort and disrupt existing implementations.
While benchmarks show it's fast for shell scripts, parsing speed is inherently slower than compiled language parsers, which might be a bottleneck in high-performance applications.
Using features like embedding or pre-generation requires additional steps with gengetoptions, adding initial overhead compared to simpler inline parsing methods.