Skip to content

Commit b7a6888

Browse files
authored
bash tab completion for launcher + discourse-setup (#676)
add tab completion for launcher and discourse-setup. For launcher, offers command (e.g., rebuild, start) and then offers yml files from containers directory. After that switches (e.g., --run-image) are offered. (Will not offer switches except in final position, sorry.) discourse-setup offers switches (e.g., --two-container). discourse-docter has no command line arguments.
1 parent 9f80d83 commit b7a6888

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

scripts/launcher-completion.bash

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env bash
2+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
3+
CONTAINER_DIR=$DIR/../containers/
4+
5+
_containers_compgen_filenames() {
6+
local cur="$1"
7+
compgen -G "$CONTAINER_DIR$cur*.yml" -- $CONTAINER_DIR"$cur" | xargs -n 1 basename -s .yml
8+
}
9+
10+
_launcher ()
11+
{
12+
local cur
13+
14+
switches='--skip-prereqs --docker-args --skip-mac-address --run-image'
15+
commands='start stop restart destroy enter logs bootstrap run rebuild cleanup start-cmd'
16+
17+
COMPREPLY=()
18+
cur=${COMP_WORDS[COMP_CWORD]}
19+
20+
case $COMP_CWORD in
21+
1)
22+
COMPREPLY=( $( compgen -W "$commands" -- $cur ) );;
23+
2)
24+
COMPREPLY=( $(_containers_compgen_filenames "$cur") ) ;;
25+
*)
26+
COMPREPLY=( $( compgen -W "$switches" -- $cur ) );;
27+
esac
28+
return 0
29+
}
30+
31+
_discourse_setup()
32+
{
33+
local cur
34+
switches='--debug --skip-rebuild --two-container --skip-connection-test'
35+
36+
cur=${COMP_WORDS[COMP_CWORD]}
37+
COMPREPLY=( $(compgen -W "$switches" -- $cur ) )
38+
return 0
39+
}
40+
41+
complete -F _launcher launcher
42+
complete -F _launcher ./launcher
43+
complete -F _discourse_setup discourse-setup
44+
complete -F _discourse_setup ./discourse-setup

0 commit comments

Comments
 (0)