File: boinc.bash

package info (click to toggle)
boinc 7.14.2%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 111,132 kB
  • sloc: cpp: 163,589; php: 113,173; ansic: 49,284; pascal: 35,620; xml: 17,864; java: 13,521; python: 6,551; sh: 4,082; perl: 1,843; makefile: 1,796; objc: 1,543; sql: 959; csh: 126; lisp: 47
file content (94 lines) | stat: -rw-r--r-- 2,736 bytes parent folder | download | duplicates (12)
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
# Source this file in BASH to get command completion (using tab) for
# boinc and boinccmd. Written by Frank S. Thomas <fst@debian.org>.
# See also: http://boinc.berkeley.edu/trac/wiki/BashCommandCompletion

_boinc()
{
    local cur prev opts
    COMPREPLY=()
    cur="${COMP_WORDS[COMP_CWORD]}"
    prev="${COMP_WORDS[COMP_CWORD-1]}"

    opts="$(boinc --help | \
        sed -n -r 's/^[[:space:]]*(--[a-z_]*).*/\1/p')"

    # Handle options that require one or more arguments.
    case "$prev" in
        --attach_project|--detach_project|--reset_project|--update_prefs|\
        --gui_rpc_port|--start_delay|--dir)
            return 0
        ;;
    esac

    # Handle options that require two arguments.
    if [[ COMP_CWORD -gt 1 ]]; then
        pprev="${COMP_WORDS[COMP_CWORD-2]}"

        case "$pprev" in
            --attach_project)
                return 0
            ;;
        esac
    fi

    if [[ "$cur" == -* ]]; then
        COMPREPLY=( $(compgen -W "$opts" -- "$cur") )
        return 0
    fi
}
complete -F _boinc -o default boinc

_boinccmd()
{
    local cur prev opts cmds
    COMPREPLY=()
    cur="${COMP_WORDS[COMP_CWORD]}"
    prev="${COMP_WORDS[COMP_CWORD-1]}"

    opts="--host --passwd -h --help -V --version"
    cmds="$(boinccmd --help 2>&1 | \
        sed -n -r 's/^[[:space:]]*(--[a-z_]*).*/\1/p')"

    # The following construct assures that:
    # - no command follows if one of $opts or $cmds was given
    # - after --host follows only one command or --passwd and one command
    # - after --passwd follows only one command
    if [[ $COMP_CWORD -eq 1 ]]; then
        COMPREPLY=( $(compgen -W "$opts $cmds" -- "$cur") )
        return 0
    else
        if [[ "${COMP_WORDS[@]}" =~ ".* --host .* --passwd .*" ]]; then
            if [[ $COMP_CWORD -eq 5 ]]; then
                COMPREPLY=( $(compgen -W "$cmds" -- "$cur") )
            fi
        elif [[ "${COMP_WORDS[@]}" =~ ".* --passwd .*" ]]; then
            if [[ $COMP_CWORD -eq 3 ]]; then
                COMPREPLY=( $(compgen -W "$cmds" -- "$cur") )
            fi
        elif [[ "${COMP_WORDS[@]}" =~ ".* --host .*" ]]; then
            if [[ $COMP_CWORD -eq 3 ]]; then
                COMPREPLY=( $(compgen -W "--passwd $cmds" -- "$cur") )
            fi
       fi
    fi

    # Handle options/commands that require one or more arguments.
    case "$prev" in
        --get_messages|--passwd|--get_notices)
            return 0
        ;;

        --host)
            _known_hosts
            return 0
        ;;

        --set_run_mode|--set_network_mode|--set_gpu_mode)
            COMPREPLY=( $(compgen -W "always auto never" -- "$cur") )
            return 0
        ;;
    esac
}
complete -F _boinccmd boinccmd

# vim: syntax=sh