summaryrefslogtreecommitdiffstats
path: root/completions/_udevadm
blob: 6a3c351b01395f64ef34f8e85317e2d9a73e87b3 (plain)
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
# udevadm(8) completion                                    -*- shell-script -*-

# Use of this file is deprecated.  Upstream completion is available in
# systemd >= 196, use that instead.

_comp_cmd_udevadm()
{
    local cur prev words cword was_split comp_args
    _comp_initialize -s -- "$@" || return

    local i udevcmd="" has_udevcmd=""
    for ((i = 1; i < cword; i++)); do
        if [[ ${words[i]} != -* ]]; then
            udevcmd=${words[i]}
            has_udevcmd=set
            break
        fi
    done

    case $prev in
        --help | --version | --property | --children-max | --timeout | \
            --seq-start | --seq-end | --attr-match | --attr-nomatch | \
            --parent-match | --property-match | --tag-match | \
            --subsystem-match | --subsystem-nomatch | --sysname-match | --path)
            return
            ;;
        --log-priority)
            _comp_compgen -- -W 'err info debug'
            return
            ;;
        --query)
            _comp_compgen -- -W 'name symlink path property all'
            return
            ;;
        --name)
            _comp_compgen -c "${cur:-/dev/}" filedir
            return
            ;;
        --device-id-of-file | --exit-if-exists)
            _comp_compgen_filedir
            return
            ;;
        --action)
            _comp_compgen -- -W 'add change remove'
            return
            ;;
        --type)
            _comp_compgen -- -W 'devices subsystems failed'
            return
            ;;
    esac

    [[ $was_split ]] && return

    if [[ ! $has_udevcmd ]]; then
        case $cur in
            -*)
                _comp_compgen -- -W '--help --version --debug'
                ;;
            *)
                _comp_compgen_split -- "$("$1" --help 2>/dev/null |
                    _comp_awk '/^[ \t]/ { print $1 }')"
                ;;
        esac
        return
    fi

    if [[ $cur == -* ]]; then
        _comp_compgen_help -- ${has_udevcmd:+"$udevcmd"} --help
        [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
    fi
} &&
    complete -F _comp_cmd_udevadm udevadm

# ex: filetype=sh