Bug 10003: bash-completion for koha-list and other scripts
authorTomas Cohen Arazi <tomascohen@gmail.com>
Thu, 29 Aug 2013 19:03:11 +0000 (16:03 -0300)
committerGalen Charlton <gmc@esilibrary.com>
Mon, 5 May 2014 16:03:00 +0000 (16:03 +0000)
commitfd0e8ff0adeff322c3defea0b4f6b29bde7ffa51
tree42b307673e63bcf46a04688763677adf392203bd
parent15a5140f3673185136d6465b300813ff1c0097d4
Bug 10003: bash-completion for koha-list and other scripts

This patch implements bash-completion for the following commands:

 - koha-list
 - koha-enable
 - koha-disable
 - koha-email-enable
 - koha-email-disable
 - koha-enable-sip
 - koha-start-sip
 - koha-restart-sip
 - koha-stop-sip
 - koha-start-zebra
 - koha-stop-zebra
 - koha-restart-zebra

It is implemented in a way that it removes already used or mutually
exclusive parameters (instance names, option switches).
I already have written completion for other (more complex) commands,
but I belive a simpler patch is better to start with.

IMPORTANT: this patch relies on having the koha-list command available
in the path.

To test:
 - Make sure you have bash-completion installed and enabled (IRC might
   help us if you encounter problems).
 - Apply the patch.
Option 1:
 - Pick the debian/koha-common.bash-completion file and do
   $ cp debian/koha-common.bash-completion /etc/bash_completion.d/koha-common
 - Open a new bash shell (I do it opening a new terminal on my Ubuntu box).
 - Type one of the listed commands...
  And repeatedly press <TAB>.
 - Enjoy, and signoff if you belive it is usable. Otherwise report back.
Option 2:
 - run:
   $ . debian/koha-common.bash-completion
 - Type one of the listed commands...
  And repeatedly press <TAB>.
 - Enjoy, and signoff if you belive it is usable. Otherwise report back.

Tests:
- Some koha-list option switches are mutually exclusive, -h should be
  available in any context
- koha-enable should only autocomplete disabled instances
- koha-disable should only autocomplete enabled instances
- koha-email-enable should only autocomplete email-disabled instances
- koha-email-disable should only autocomplete email-enabled instances
- koha-*-zebra scripts should only autocomplete enabled instances.
- koha-*-sip scripts should only autocomplete sip-enabled instances.

Regards
To+

Note: writing bash-completion routines is a bit hacky, I tried to make
it the simplest way I could. Your comments are welcome.

Sponsored-by: Universidad Nacional de Cordoba
Signed-off-by: Dobrica Pavlinusic <dpavlin@rot13.org>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
debian/koha-common.bash-completion [new file with mode: 0644]
debian/rules