2021-10-23 19:36:21 +01:00
# getopt
2023-05-30 19:37:28 +01:00
> Parse command-line arguments.
2021-10-23 19:36:21 +01:00
> More information: <https://www.gnu.org/software/libc/manual/html_node/Getopt.html>.
- Parse optional `verbose` /`version` flags with shorthands:
2021-11-22 15:04:35 +00:00
`getopt --options vV --longoptions verbose,version -- --version --verbose`
2021-10-23 19:36:21 +01:00
- Add a `--file` option with a required argument with shorthand `-f` :
2021-11-22 15:04:35 +00:00
`getopt --options f: --longoptions file: -- --file=somefile`
2021-10-23 19:36:21 +01:00
- Add a `--verbose` option with an optional argument with shorthand `-v` , and pass a non-option parameter `arg` :
2021-11-22 15:04:35 +00:00
`getopt --options v:: --longoptions verbose:: -- --verbose arg`
2021-10-23 19:36:21 +01:00
- Accept a `-r` and `--verbose` flag, a `--accept` option with an optional argument and add a `--target` with a required argument option with shorthands:
2021-11-22 15:04:35 +00:00
`getopt --options rv::s::t: --longoptions verbose,source::,target: -- -v --target target`