xref: /aosp_15_r20/external/flashrom/util/flashrom.bash-completion.tmpl (revision 0d6140be3aa665ecc836e8907834fcd3e3b018fc)
1# Completion file for bash
2#
3# This file is part of the flashrom project.
4#
5# Copyright 2022 Alexander Goncharov <[email protected]>
6#
7# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 2 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15# GNU General Public License for more details.
16#
17
18_flashrom()
19{
20	local cur prev OPTS
21	COMPREPLY=()
22	cur="${COMP_WORDS[COMP_CWORD]}"
23	prev="${COMP_WORDS[COMP_CWORD-1]}"
24	case $prev in
25		'-r'|'--read'|'-w'|'--write'|'-v'|'--verify'|'-l'|'--layout'| \
26		'--fmap-file'|'-o'|'--output'|'--flash-contents')
27			local IFS=$'\n'
28			compopt -o filenames
29			COMPREPLY=( $(compgen -f -- $cur) )
30			return 0
31			;;
32		'-c'|'--chip'|'--wp-range'|'--wp-region'|'-i'|'--include')
33			return 0
34			;;
35		'-p'|'--programmer')
36			COMPREPLY=( $(compgen -W "@PROGRAMMERS@" -- $cur) )
37			return 0
38			;;
39		'-h'|'--help'|'-R'|'--version'|'-L'|'--list-supported')
40			return 0
41			;;
42	esac
43	OPTS="--help
44		--version
45		--read
46		--write
47		--verify
48		--erase
49		--verbose
50		--chip
51		--force
52		--noverify
53		--noverify-all
54		--extract
55		--layout
56		--wp-disable
57		--wp-enable
58		--wp-list
59		--wp-status
60		--wp-range
61		--wp-region
62		--flash-name
63		--flash-size
64		--fmap
65		--fmap-file
66		--ifd
67		--include
68		--output
69		--flash-contents
70		--list-supported
71		--progress
72		--programmer"
73	COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
74	return 0
75}
76
77complete -F _flashrom flashrom
78