1 # Source this file in BASH to get command completion (using tab) for
2 # boinc and boinccmd. Written by Frank S. Thomas <fst@debian.org>.
3 # See also: http://boinc.berkeley.edu/trac/wiki/BashCommandCompletion
9 cur
="${COMP_WORDS[COMP_CWORD]}"
10 prev
="${COMP_WORDS[COMP_CWORD-1]}"
12 opts
="$(boinc_client --help | \
13 sed -n -r 's/^[[:space:]]*(--[a-z_]*).*/\1/p')"
15 # Handle options that require one or more arguments.
17 --attach_project|
--detach_project|
--reset_project|
--update_prefs|\
23 # Handle options that require two arguments.
24 if [[ COMP_CWORD
-gt 1 ]]; then
25 pprev
="${COMP_WORDS[COMP_CWORD-2]}"
34 if [[ "$cur" == -* ]]; then
35 COMPREPLY
=( $
(compgen
-W "$opts" -- "$cur") )
39 complete
-F _boinc
-o default boinc_client
43 local cur prev opts cmds
45 cur
="${COMP_WORDS[COMP_CWORD]}"
46 prev
="${COMP_WORDS[COMP_CWORD-1]}"
48 opts
="--host --passwd -h --help -V --version"
49 cmds
="$(boinc_cmd --help 2>&1 | \
50 sed -n -r 's/^[[:space:]]*(--[a-z_]*).*/\1/p')"
52 # The following construct assures that:
53 # - no command follows if one of $opts or $cmds was given
54 # - after --host follows only one command or --passwd and one command
55 # - after --passwd follows only one command
56 if [[ $COMP_CWORD -eq 1 ]]; then
57 COMPREPLY
=( $
(compgen
-W "$opts $cmds" -- "$cur") )
60 if [[ "${COMP_WORDS[@]}" =~
".* --host .* --passwd .*" ]]; then
61 if [[ $COMP_CWORD -eq 5 ]]; then
62 COMPREPLY
=( $
(compgen
-W "$cmds" -- "$cur") )
64 elif [[ "${COMP_WORDS[@]}" =~
".* --passwd .*" ]]; then
65 if [[ $COMP_CWORD -eq 3 ]]; then
66 COMPREPLY
=( $
(compgen
-W "$cmds" -- "$cur") )
68 elif [[ "${COMP_WORDS[@]}" =~
".* --host .*" ]]; then
69 if [[ $COMP_CWORD -eq 3 ]]; then
70 COMPREPLY
=( $
(compgen
-W "--passwd $cmds" -- "$cur") )
75 # Handle options/commands that require one or more arguments.
77 --get_messages|
--passwd)
86 --set_run_mode|
--set_network_mode)
87 COMPREPLY
=( $
(compgen
-W "always auto never" -- "$cur") )
91 --set_screensaver_mode)
92 COMPREPLY
=( $
(compgen
-W "on off" -- "$cur") )
97 complete
-F _boinccmd boinc_cmd