-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathasadmin-completion.bash
More file actions
executable file
·131 lines (128 loc) · 3.59 KB
/
asadmin-completion.bash
File metadata and controls
executable file
·131 lines (128 loc) · 3.59 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# bash completion for asadmin(1) -*- shell-script -*-
#
# asadmin-completion
# ===================
#
# Bash completion support for [Glassfish](http://glassfish.java.net) `asadmin'
#
# The contained completion routines provide support for completing:
#
# * asadmin start-domain, stop-domain, list-applications
# * deploy war, jar or ear files
# * deploy directories
#
#
# Installation
# ------------
#
# To achieve asadmin completion nirvana:
#
# 0. Install bash-completion.
#
# 1. Install this file. Either:
#
# a. Place it in a `bash-completion.d` folder:
#
# * /etc/bash-completion.d
# * /usr/local/etc/bash-completion.d
# * ~/bash-completion.d
#
# b. Or, copy it somewhere (e.g. ~/.asadmin-completion.bash) and put the following line in
# your .bashrc:
#
# source ~/.asadmin-completion.bash
#
_have asadmin &&
_asadmin_list_commands()
{
echo "
list-applications
list-commands
list-connector-connection-pools
list-connector-resources
list-connector-security-maps
list-http-listeners
list-javamail-resources
list-jdbc-connection-pools
list-jdbc-resources
list-jms-resources
list-jmsdest
list-jndi-entries
list-threadpools
list-virtual-servers
"
} &&
_asadmin_misc_commands()
{
echo "verify-domain-xml generate-jvm-report flush-connection-pool flush-jmsdest"
} &&
_asadmin_commands()
{
# just a subset of all commands (asadmin list-commands shows all)
echo "start-domain stop-domain deploy undeploy `_asadmin_list_commands` `_asadmin_misc_commands`"
} &&
_asadmin_start_domain_options()
{
echo "--debug=true"
} &&
_asadmin_undeploy_commands()
{
asadmin list-applications | sed -e 's/^\([^<]\+\) \+<.\+$/\1/g' -e '/^Command list-applications executed successfully./Q'
} &&
_asadmin_flush_connection_pool_commands()
{
asadmin list-jdbc-connection-pools | grep -v '^Command .* executed successfully.'
} &&
_asadmin_flush_jmsdest_commands()
{
asadmin list-jmsdest | grep -v '^Command .* executed successfully.'
} &&
_asadmin()
{
local cur prev words cword
_init_completion || return
COMPREPLY=()
if [ $COMP_CWORD -eq 1 ]; then
COMPREPLY=( $( compgen -W "--help $(_asadmin_commands)" -- $cur ) )
elif [ $COMP_CWORD -gt 1 ]; then
case "$prev" in
start-domain)
COMPREPLY=( $( compgen -W "--help $(_asadmin_start_domain_options)" -- $cur ) )
return 0
;;
stop-domain)
COMPREPLY=( $( compgen -W "--help" -- $cur ) )
return 0
;;
undeploy)
COMPREPLY=( $( compgen -W "--help $(_asadmin_undeploy_commands)" -- $cur ) )
return 0
;;
flush-connection-pool)
COMPREPLY=( $( compgen -W "--help $(_asadmin_flush_connection_pool_commands)" -- $cur ) )
return 0
;;
flush-jmsdest)
COMPREPLY=( $( compgen -W "--help --desttype=queue" -- $cur ) )
return 0
;;
--desttype=queue)
COMPREPLY=( $( compgen -W "$(_asadmin_flush_jmsdest_commands)" -- $cur ) )
return 0
;;
deploy)
COMPREPLY=( $( compgen -W "--help --force" -- $cur ) )
_filedir '@(ear|war|jar)'
return 0
;;
--force)
_filedir '@(ear|war|jar)'
return 0
;;
list-threadpools)
COMPREPLY=( $( compgen -W "--help server" -- $cur ) )
return 0
;;
esac
fi
} && complete -F _asadmin asadmin