summaryrefslogtreecommitdiffstats
path: root/completion/dmidecode.bash
blob: 200d6cdfb345eb89cc1aa44266206780c828acfd (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
# bash completion for dmidecode                            -*- shell-script -*-

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

	case $prev in
	-d | --dev-mem | --dump-bin | --from-dump)
		if [[ $prev == -d || $prev == --dev-mem ]]; then
			: "${cur:=/dev/}"
		fi
		local IFS=$'\n'
		compopt -o filenames
		COMPREPLY=($(compgen -f -- "$cur"))
		return 0
		;;
	-s | --string)
		COMPREPLY=($(compgen -W '$("$1" --list-strings)' -- "$cur"))
		return 0
		;;
	-t | --type)
		COMPREPLY=($(compgen -W '$("$1" --list-types)' -- "$cur"))
		return 0
		;;
	--dump-bin | --from-dump)
		local IFS=$'\n'
		compopt -o filenames
		COMPREPLY=($(compgen -f -- "$cur"))
		return 0
		;;
	-[hVH] | --help | --version | --handle | --oem-string)
		return 0
		;;
	esac

	if [[ $cur == -* ]]; then
		COMPREPLY=($(compgen -W '
			--dev-mem
			--help
			--quiet
			--string
			--list-strings
			--type
			--list-types
			--handle
			--dump
			--dump-bin
			--from-dump
			--no-sysfs
			--oem-string
			--version
		' -- "$cur"))
		return 0
	fi

} && complete -F _comp_cmd_dmidecode dmidecode

# ex: filetype=sh