Auto completing wadm commands

Taking a cue from a blog written by my friend Harsha, I thought why not try the same for wadm, the new CLI in Web Server 7.0 Now that wadm has some 300+ commands to perform various administrative tasks, auto completing (or tab completion) commands is a great help!

wadm comes with an auto completor for commands in shell mode. But for running wadm commands in single mode, you need to be aware of the command name and usage.

For those who don't know, bash has a feature called programmable auto completion ('man bash' for more info). What it means is that you can add your own rules for completing custom commands.

Just follow these steps to set up wadm (which I did on my Ubuntu):

1. Create /etc/bash_completion.d if it doesn't already exist.

2. Save this script as wadm in /etc/bash_completion.d

3. Save this commands and options file as wadm_commands.txt in /etc/bash_completion.d

4. Source the script into your shell and start tabbing!

$ cd <install-root>/bin
$ source /etc/bash_completion.d/wadm
$ wadm l[TAB]ist-[TAB][TAB]
list-acls                                            list-error-pages                                     list-mail-resources
list-auth-realm-userprops              list-events                                              list-mime-types
list-auth-realms                              list-external-jndi-resource-userprops  list-nodes
list-authdb-userprops                    list-external-jndi-resources                  list-org-units
list-authdbs                                    list-group-members                               list-reverse-proxy-headers
list-certs                                          list-groups                                             list-reverse-proxy-uris
list-cgi-dirs                                      list-http-listeners                                  list-search-collections
list-cgi-envvars                               list-instances                                         list-soap-auth-provider-userprops
list-ciphers                                     list-jdbc-resource-userprops                 list-soap-auth-providers
list-config-files                               list-jdbc-resources                                 list-tokens
list-configs                                      list-jvm-options                                      list-uri-patterns
list-crls                                            list-jvm-profilers                                    list-url-redirects
list-custom-resource-userprops    list-lifecycle-module-userprops            list-users
list-custom-resources                    list-lifecycle-modules                             list-virtual-servers
list-dav-collections                         list-locks                                                 list-webapps
list-document-dirs                         list-mail-resource-userprops
bash-3.00$ wadm list-n[TAB]odes [TAB]--[TAB][TAB]
--all            --host                --no-ssl               --port           --user
--echo        --no-prompt      --password-file  --rcfile         --verbose


As an added tip, I have the following setting in ~/.inputrc file which enables auto completion on single [TAB] key press. Double tab press is the default intended behaviour.

$ cat ~/.inputrc
set show-all-if-ambiguous on




Comments:

Nice integration. Keep it up!

Posted by Kedar Mhaswade on December 13, 2006 at 03:41 AM IST #

Post a Comment:
  • HTML Syntax: NOT allowed
About

yamini

Search

Top Tags
Archives
« May 2015
SunMonTueWedThuFriSat
     
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
      
Today