gsu: Initial completion support.
authorAndre Noll <maan@systemlinux.org>
Fri, 23 Sep 2011 15:21:58 +0000 (17:21 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Fri, 29 Aug 2014 19:39:58 +0000 (21:39 +0200)
commit2783dd4b09077392ab69857b9248e1c68bae7fe8
treea1e7ff123b384c03088a1e89e397f0734017d177
parentc75c58e9aec5a02ffe5245df373d3eeb432769b2
gsu: Initial completion support.

This adds the framework for command completion of scripts which make
use of the gsu subcommand library. The idea is to implement as much
as possible as generic helpers within gsu in order to minimize code
duplication in the scripts which source the gsu library.

The new "complete" subcommand is automatically included in each
application, just like the help, man and prefs commands we already
have. This subommand is meant to be used as the completer which calls
the custom subcommand completers included in the application.

Two new public helper functions, gsu_complete_options() and
gsu_cword_is_option_parameter() are introduced in this commit.

The former function takes a usual getopt string and completes according
to all options in this string. The latter is useful for completers
which need to determine whether the current word is the parameter to
some option in order to find out how to complete the current word.

For example, the -s option of cmt's vmem command takes a mandatory
parameter which is a number. So the completer for this command must
complete differently depending on whether the previous word is "-s".
misc/gsu/subcommand