The Bash Argsparse Library 1.8
An high level argument parsing library for bash.
Loading...
Searching...
No Matches
Bash Completion-related functions.

argsparse-completion relies on a few shell settings:

argsparse-completion relies on a few shell settings:

URL
https://github.com/Anvil/bash-argsparse
Purpose
To automatically enable, for bash-completion users, completion for scripts that use the argsparse library.
Usage
In your ~/.bashrc, add the following lines to enable completion for all your argsparse-written scripts:
. argsparse-completion.sh
complete -F _argsparse_complete [ your scripts names ... ]
Required configuration
  • "sourcepath" shell option must be enabled. This should be enabled by default, but you can enforce it by running:
shopt -s sourcepath

If correctly enabled, the following command below should return this output.

$ shopt sourcepath
sourcepath on
Limitations
  • Every time the completion is invoked, the completed script will be sourced, up to either the argsparse_parse_options() function call or any the first return top-level statement. This means that up to this point the script should not have any side effect (like file system alteration, network connections, ...), and should avoid time-consuming tasks up to this point.
  • Only a limited set of option types completion are currently implemented.