summaryrefslogtreecommitdiffstats
path: root/completions/smartctl
blob: 376ceb8f6f02f0725a2ecb60058c5a9b682079c5 (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
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
# bash completion for smartctl(8)                          -*- shell-script -*-

_comp_cmd_smartctl__device()
{
    case $cur in
        areca* | 3ware* | megaraid* | cciss*)
            _comp_compgen -- -W '${cur%%,*},{0..31}'
            ;;
        hpt*)
            _comp_compgen -- -W 'hpt,{1..4}/{1..8} hpt,{1..4}/{1..8}/{1..5}'
            ;;
        *)
            _comp_compgen -- -W 'ata scsi sat usbcypress usbjmicron usbsunplus
                marvell areca 3ware hpt megaraid cciss auto test'
            case "${COMPREPLY[@]}" in
                areca | 3ware | hpt | megaraid | cciss)
                    compopt -o nospace
                    ;;
            esac
            ;;
    esac
}
_comp_cmd_smartctl__test()
{
    [[ $cur == @(pending|scttempint|vendor), ]] && return
    _comp_compgen -- -W 'offline short long conveyance select, select,redo
        select,next afterselect,on afterselect,off pending, scttempint,
        vendor,'
    [[ ${COMPREPLY-} == *, ]] && compopt -o nospace
}
_comp_cmd_smartctl__drivedb()
{
    local prefix=
    if [[ $cur == +* ]]; then
        prefix=+
        cur="${cur#+}"
    fi
    _comp_compgen_filedir h && [[ $prefix ]] &&
        _comp_compgen -Rv COMPREPLY -- -P "$prefix" -W '"${COMPREPLY[@]}"'
}

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

    local noargopts='!(-*|*[qdTbrnsoSlvFPBt]*)'
    # shellcheck disable=SC2254
    case $prev in
        --quietmode | -${noargopts}q)
            _comp_compgen -- -W 'errorsonly silent noserial'
            return
            ;;
        --device | -${noargopts}d)
            _comp_cmd_smartctl__device
            return
            ;;
        --tolerance | -${noargopts}T)
            _comp_compgen -- -W 'normal conservative permissive verypermissive'
            return
            ;;
        --badsum | -${noargopts}b)
            _comp_compgen -- -W 'warn exit ignore'
            return
            ;;
        --report | -${noargopts}r)
            _comp_compgen -- -W 'ioctl ataioctl scsiioctl'
            return
            ;;
        --nocheck | -${noargopts}n)
            _comp_compgen -- -W 'never sleep standby idle'
            return
            ;;
        --smart | --offlineauto | --saveauto | -${noargopts}[soS])
            _comp_compgen -- -W 'on off'
            return
            ;;
        --log | -${noargopts}l)
            _comp_compgen -- -W 'error selftest selective directory background
                sasphy sasphy,reset sataphy sataphy,reset scttemp scttempsts
                scttemphist scterc gplog smartlog xerror xselftest'
            return
            ;;
        --vendorattribute | -${noargopts}v)
            _comp_compgen -- -W 'help 9,minutes 9,seconds 9,halfminutes 9,temp
                192,emergencyretractcyclect 193,loadunload 194,10xCelsius
                194,unknown 198,offlinescanuncsectorct 200,writeerrorcount
                201,detectedtacount 220,temp'
            return
            ;;
        --firmwarebug | -${noargopts}F)
            _comp_compgen -- -W 'none samsung samsung2 samsung3 swapid'
            return
            ;;
        --presets | -${noargopts}P)
            _comp_compgen -- -W 'use ignore show showall'
            return
            ;;
        --drivedb | -${noargopts}B)
            _comp_cmd_smartctl__drivedb
            return
            ;;
        --test | -${noargopts}t)
            _comp_cmd_smartctl__test
            return
            ;;
    esac

    [[ $was_split ]] && return

    if [[ $cur == -* ]]; then
        _comp_compgen_help
        [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
    else
        _comp_compgen -c "${cur:-/dev/}" filedir
    fi
} &&
    complete -F _comp_cmd_smartctl smartctl

# ex: filetype=sh