summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorAlexander Goncharov <chat@joursoir.net>2022-10-09 13:10:27 +0300
committerAnastasia Klimchuk <aklm@chromium.org>2023-01-18 21:04:58 +0000
commit58888f78f3690e6701a717cdc65562fdf9038e1e (patch)
tree0d253993cbac31f3f9229878aaf0d2e4e54875f5 /util
parent87531ef11c00963100f20fac71c2428f54162916 (diff)
downloadflashrom-58888f78f3690e6701a717cdc65562fdf9038e1e.tar.gz
flashrom-58888f78f3690e6701a717cdc65562fdf9038e1e.tar.bz2
flashrom-58888f78f3690e6701a717cdc65562fdf9038e1e.zip
util: add bash completion script
Add a bash script for the flashrom CLI that auto-completes the command sequence. The script is generated from a template by substituting a list of enabled programmers. It requires an extra `bash-completion` package to work, but, fortunately, it's installed on most systems. Build system changes: meson: provide option `bash_completion` to determine if the script should be installed (depends on option `classic_cli`). makefile: make a list of enabled programmers (by using CONFIG_* variables) to do substitution manually Change-Id: Ie68bc91c3cea4de2ffdbeffd07e48edd8d5590e1 Signed-off-by: Alexander Goncharov <chat@joursoir.net> Reviewed-on: https://review.coreboot.org/c/flashrom/+/68247 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de> Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Diffstat (limited to 'util')
-rw-r--r--util/flashrom.bash-completion.tmpl77
1 files changed, 77 insertions, 0 deletions
diff --git a/util/flashrom.bash-completion.tmpl b/util/flashrom.bash-completion.tmpl
new file mode 100644
index 000000000..afb7ae98c
--- /dev/null
+++ b/util/flashrom.bash-completion.tmpl
@@ -0,0 +1,77 @@
+# Completion file for bash
+#
+# This file is part of the flashrom project.
+#
+# Copyright 2022 Alexander Goncharov <chat@joursoir.net>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+
+_flashrom()
+{
+ local cur prev OPTS
+ COMPREPLY=()
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
+ case $prev in
+ '-r'|'--read'|'-w'|'--write'|'-v'|'--verify'|'-l'|'--layout'| \
+ '--fmap-file'|'-o'|'--output'|'--flash-contents')
+ local IFS=$'\n'
+ compopt -o filenames
+ COMPREPLY=( $(compgen -f -- $cur) )
+ return 0
+ ;;
+ '-c'|'--chip'|'--wp-range'|'--wp-region'|'-i'|'--include')
+ return 0
+ ;;
+ '-p'|'--programmer')
+ COMPREPLY=( $(compgen -W "@PROGRAMMERS@" -- $cur) )
+ return 0
+ ;;
+ '-h'|'--help'|'-R'|'--version'|'-L'|'--list-supported')
+ return 0
+ ;;
+ esac
+ OPTS="--help
+ --version
+ --read
+ --write
+ --verify
+ --erase
+ --verbose
+ --chip
+ --force
+ --noverify
+ --noverify-all
+ --extract
+ --layout
+ --wp-disable
+ --wp-enable
+ --wp-list
+ --wp-status
+ --wp-range
+ --wp-region
+ --flash-name
+ --flash-size
+ --fmap
+ --fmap-file
+ --ifd
+ --include
+ --output
+ --flash-contents
+ --list-supported
+ --progress
+ --programmer"
+ COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+ return 0
+}
+
+complete -F _flashrom flashrom