aboutsummaryrefslogtreecommitdiffstats
path: root/src/_rfkill
diff options
context:
space:
mode:
authorShohei YOSHIDA <syohex@gmail.com>2023-07-01 12:01:53 +0900
committerShohei YOSHIDA <syohex@gmail.com>2023-07-02 09:41:31 +0900
commit3a817b893e9f06e619cea0d3d767d6d7452b4146 (patch)
tree80264964913a8e6b651ee23b89059c30c431751e /src/_rfkill
parentMerge pull request #1020 from zsh-users/update-rspec (diff)
downloadzsh-completions-3a817b893e9f06e619cea0d3d767d6d7452b4146.tar
zsh-completions-3a817b893e9f06e619cea0d3d767d6d7452b4146.tar.gz
zsh-completions-3a817b893e9f06e619cea0d3d767d6d7452b4146.tar.bz2
zsh-completions-3a817b893e9f06e619cea0d3d767d6d7452b4146.tar.lz
zsh-completions-3a817b893e9f06e619cea0d3d767d6d7452b4146.tar.xz
zsh-completions-3a817b893e9f06e619cea0d3d767d6d7452b4146.tar.zst
zsh-completions-3a817b893e9f06e619cea0d3d767d6d7452b4146.zip
Update rfkill completion
Diffstat (limited to 'src/_rfkill')
-rw-r--r--src/_rfkill49
1 files changed, 29 insertions, 20 deletions
diff --git a/src/_rfkill b/src/_rfkill
index 8539bef..55b6cd6 100644
--- a/src/_rfkill
+++ b/src/_rfkill
@@ -18,19 +18,19 @@
# Description
# -----------
#
-# Completion script for rfkill (https://wireless.wiki.kernel.org/en/users/Documentation/rfkill)
+# Completion script for rfkill 2.38.1 (https://wireless.wiki.kernel.org/en/users/Documentation/rfkill)
#
# ------------------------------------------------------------------------------
# Authors
# -------
#
# * Vincent Bernat <bernat@luffy.cx>
+# * Shohei YOSHIDA <https://github.com/syohex>
#
# ------------------------------------------------------------------------------
_rfkill_types() {
- declare -a devicetypes
- devicetypes=(all
+ local -a devicetypes=(all
"wifi:Wireless LAN" "wlan:Wireless LAN"
"bluetooth:Bluetooth"
"uwb:Ultrawide Band"
@@ -44,30 +44,36 @@ _rfkill_types() {
}
_rfkill_devices() {
- declare -a devices
- devices=(${(M)${(f)"$(rfkill list)"}:#[0-9]*})
+ local -a devices=(${(M)${(f)"$(rfkill list)"}:#[0-9]*})
_rfkill_types
_describe -t devices "devices" devices
}
-_rfkill_commands () {
- declare -a subcommands
- subcommands=(help event list block unblock)
- _describe -t rfkill-commands "rfkill command" subcommands
+_rfkill_columns() {
+ local -a columns=(DEVICE ID TYPE TYPE-DESC SOFT HARD)
+ _values -s ',' 'column' $columns
}
-_rfkill_subcommand () {
+_rfkill_command() {
+ local -a commands=(
+ 'help:display help text and exit'
+ 'event:listen for rfkill events and display them on stdout'
+ 'list:list the current state of all available devices'
+ 'block:disable the corresponding device'
+ 'unblock:enable the corresponding device'
+ 'toggle:enable or disable the corresponding device'
+ )
+ _describe -t commands 'command' commands "$@"
+}
+
+_rfkill_subcommand() {
case "$words[1]" in
- (help|event)
- ;;
(list)
_arguments ':types:_rfkill_types'
;;
- (block|unblock)
+ (block|unblock|toggle)
_arguments ':device:_rfkill_devices'
;;
- (*)
- _message 'Unknown subcommand'
esac
}
@@ -76,14 +82,17 @@ _rfkill () {
typeset -A opt_args
_arguments -C \
- '--version[get version]:' \
- '(-): :->command' \
+ '(* -)'{-h,--help}'[display help]' \
+ '(* -)'{-V,--version}'[get version]' \
+ '(-J --json -r --raw)'{-J,--json}'[use JSON output format]' \
+ '(-n --noheadings)'{-n,--noheadings}"[don't print headings]" \
+ '(-o --output --output-all)'{-o,--output}'[define which output columns to use]:column_list:_rfkill_columns' \
+ '(-o --output --output-all)--output-all[output all columns]' \
+ '(-J --json -r --raw)'{-r,--raw}'[use the raw output format]' \
+ '(-): :_rfkill_command' \
'(-)*:: :->arguments'
case $state in
- (command)
- _rfkill_commands
- ;;
(arguments)
curcontext=${curcontext%:*:*}:rfkill-$words[1]:
_rfkill_subcommand