Make it obvious that the option expects an argument by appending the equal sign on completion. Suspend space in this case. The regular expression in `output-options.sh` is adjusted to take into account this on processing option strings.
24 lines
637 B
Bash
Executable File
24 lines
637 B
Bash
Executable File
#!/bin/bash
|
|
# Output short and long options from man/usage text
|
|
|
|
set -o errexit -o pipefail -o nounset
|
|
|
|
main() {
|
|
declare tmpdir="_options.tmp"
|
|
declare tmp="${tmpdir}/${1:-generic}"
|
|
|
|
mkdir -p "$tmpdir"
|
|
cat > "$tmp"
|
|
|
|
# Do not propose single letter completions. It's not useful, it's noisy
|
|
# and it makes completion slower:
|
|
# Display all 200 possibilities? (y or n)
|
|
# sed -rn 's/.* (-[a-zA-Z0-9]).*/\1/gp' < "$tmp"
|
|
|
|
# Do not print '=' after long options with arg because it makes completion
|
|
# for option arguments harder.
|
|
sed -rn 's/.* (--[a-zA-Z][-_a-zA-Z0-9]*=?).*/\1/gp' < "$tmp"
|
|
}
|
|
|
|
main "$@"
|