Merge pull request #1043 from zsh-users/update-fwupdmgr

Update fwupdmgr completion to 1.8.12
This commit is contained in:
Shohei YOSHIDA 2023-09-15 18:46:43 +09:00 committed by GitHub
commit 07fe4030a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 83 additions and 197 deletions

View File

@ -3,21 +3,21 @@
# Description # Description
# ----------- # -----------
# #
# Completion script for fwupdmgr 1.2.9 (https://github.com/hughsie/fwupd). # Completion script for fwupdmgr 1.8.12 (https://github.com/hughsie/fwupd).
# #
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Authors # Authors
# ------- # -------
# #
# * Julien Nicoulaud <julien.nicoulaud@gmail.com> # * Julien Nicoulaud <julien.nicoulaud@gmail.com>
# * Shohei Yoshida (https://github.com/syohex)
# #
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
_fwupdmgr() { _fwupdmgr() {
local context state state_descr line local context state state_descr line
typeset -A opt_args typeset -A opt_args
local ret=1
_arguments -C \ _arguments -C \
'(- : *)'{-h,--help}'[display help information]' \ '(- : *)'{-h,--help}'[display help information]' \
@ -26,14 +26,22 @@ _fwupdmgr() {
--offline'[schedule installation for next reboot when possible]' \ --offline'[schedule installation for next reboot when possible]' \
--allow-reinstall'[allow re-installing existing firmware versions]' \ --allow-reinstall'[allow re-installing existing firmware versions]' \
--allow-older'[allow downgrading firmware versions]' \ --allow-older'[allow downgrading firmware versions]' \
--allow-branch-switch'[allow switching firmware branch]' \
--force'[override warnings and force the action]' \ --force'[override warnings and force the action]' \
'(-y, --assume-yes)'{-y,--assume-yes}'[answer yes to all questions]' \ '(-y, --assume-yes)'{-y,--assume-yes}'[answer yes to all questions]' \
--sign'[sign the uploaded data with the client certificate]' \ --sign'[sign the uploaded data with the client certificate]' \
--no-unreported-check'[do not check for unreported history]' \ --no-unreported-check'[do not check for unreported history]' \
--no-metadata-check'[do not check for old metadata]' \ --no-metadata-check'[do not check for old metadata]' \
--no-reboot-check'[do not check for reboot after update]' \ --no-reboot-check'[do not check for reboot after update]' \
--no-safety-check'[do not perform device safety checks]' \
--no-device-prompt'[do not prompt for devices]' \
--no-history'[do not write to the history database]' \ --no-history'[do not write to the history database]' \
--show-all-devices'[show devices that are not updatable]' \ --show-all'[show all results]' \
--disable-ssl-strict'[ignore SSL strict checks when downloading files]' \
--ipfs'[only use IPFS when downloading files]' \
--filter'[filter with a set of device flags using a ~ prefix to exclude]:filter' \
--json'[output in JSON format]' \
--no-authenticate'[do not prompt for authentication]' \
'(-): :->command' \ '(-): :->command' \
'(-)*:: :->arguments' \ '(-)*:: :->arguments' \
&& ret=0 && ret=0
@ -43,44 +51,99 @@ _fwupdmgr() {
_fwupdmgr_commands _fwupdmgr_commands
;; ;;
(arguments) (arguments)
curcontext=${curcontext%:*:*}:fwupdmgr-$words[1]: case $words[1] in
if (( $+functions[_fwupdmgr_${words[1]}_args] )); then (activate|downgrade|emulation-tag|emulation-untag|get-releases|get-updates|reinstall|update|verify|verify-update)
_fwupdmgr_${words[1]}_args _arguments \
else '1::device_id or GUID:_fwupdmgr_device_ids' \
_message "unknown command ${words[1]}" && ret=1 && ret=0
fi ;;
;; (clear-results|get-results|unlock)
(*) _arguments \
_message "unknown state $state" && ret=1 '1:device_id or GUID:_fwupdmgr_device_ids' \
&& ret=0
;;
(device-emulate|device-test|emulation-load|emulation-save|get-details|set-approved-firmware)
_arguments \
'*::files:_files' \
&& ret=0
;;
(disable-remote|modify-remote)
_arguments \
'1:remote ID:_fwupdmgr_remote_ids' \
&& ret=0
;;
(install)
_arguments \
'1:device_id or GUID:_fwupdmgr_device_ids' \
'2:version' \
&& ret=0
;;
(local-install)
_arguments \
'1:file:_files' \
'2:device_id or GUID:_fwupdmgr_device_ids' \
&& ret=0
;;
(refresh)
_arguments \
'1:file or remote ID:_alternative _files _fwupdmgr_remote_ids' \
&& ret=0
;;
(switch-branch)
_arguments \
'1:device_id or GUID:_fwupdmgr_device_ids' \
'2:branch' \
&& ret=0
;;
esac
;; ;;
esac esac
return ret
} }
(( $+functions[_fwupdmgr_commands] )) || (( $+functions[_fwupdmgr_commands] )) ||
_fwupdmgr_commands() { _fwupdmgr_commands() {
local commands=( local -a commands=(
'activate:activate devices' 'activate:activate devices'
'clear-history:erase all firmware update history' 'block-firmware:blocks a specific firmware from being installed'
'clear-offline:clears any updates scheduled to be updated offline'
'clear-results:clears the results from the last update' 'clear-results:clears the results from the last update'
'device-emulate:emulate a device using a JSON manifest'
'device-test:test a device using a JSON manifest'
'disable-remote:disables a given remote' 'disable-remote:disables a given remote'
'downgrade:downgrades the firmware on a device' 'downgrade:downgrades the firmware on a device'
'emulation-load:load device emulation data'
'emulation-save:save device emulation data'
'emulation-tag:adds devices to watch for future emulation'
'emulation-untag:removes devices to watch for future emulation'
'enable-remote:enables a given remote' 'enable-remote:enables a given remote'
'get-approved-firmware:gets the list of approved firmware' 'get-approved-firmware:gets the list of approved firmware'
'get-bios-settings:retrieve BIOS settings'
'get-blocked-firmware:gets the list of blocked firmware'
'get-details:gets details about a firmware file' 'get-details:gets details about a firmware file'
'get-devices:get all devices that support firmware updates' 'get-devices:get all devices that support firmware updates'
'get-history:show history of firmware updates' 'get-history:show history of firmware updates'
'get-plugins:get all enabled plugins registered with the system'
'get-releases:gets the releases for a device' 'get-releases:gets the releases for a device'
'get-remotes:gets the configured remotes' 'get-remotes:gets the configured remotes'
'get-results:gets the results from the last update' 'get-results:gets the results from the last update'
'get-topology:get all devices according to the system topology' 'get-topology:get all devices according to the system topology'
'get-updates:gets the list of updates for connected hardware' 'get-updates:gets the list of updates for connected hardware'
'inhibit:inhibit the system to prevent upgrades'
'install:install a firmware file on this hardware' 'install:install a firmware file on this hardware'
'local-install:install a firmware file on this hardware'
'modify-config:modifies a daemon configuration value' 'modify-config:modifies a daemon configuration value'
'modify-remote:modifies a given remote' 'modify-remote:modifies a given remote'
'quit:asks the daemon to quit'
'refresh:refresh metadata from remote server' 'refresh:refresh metadata from remote server'
'security:gets the host security attributes'
'report-history:share firmware history with the developers' 'report-history:share firmware history with the developers'
'set-approved-firmware:sets the list of approved firmware' 'set-approved-firmware:sets the list of approved firmware'
'set-bios-setting:sets one or more BIOS settings'
'switch-branch:switch the firmware branch on device'
'sync-bkc:sync firmware versions to the host best known configuration '
'unblock-firmware:unblocks a specific firmware from being installed'
'uninhibit:uninhibit the system to allow upgrades'
'unlock:unlocks the device for firmware access' 'unlock:unlocks the device for firmware access'
'update:updates all firmware to latest versions available' 'update:updates all firmware to latest versions available'
'verify:gets the cryptographic hash of the dumped firmware' 'verify:gets the cryptographic hash of the dumped firmware'
@ -89,199 +152,22 @@ _fwupdmgr_commands() {
_describe -t commands commands commands _describe -t commands commands commands
} }
(( $+functions[_fwupdmgr_activate_args] )) ||
_fwupdmgr_activate_args() {
_arguments -C \
'1: :_fwupdmgr_device_ids'
}
(( $+functions[_fwupdmgr_clear-history_args] )) ||
_fwupdmgr_clear-history_args() {
_message 'no more arguments' && ret=0
}
(( $+functions[_fwupdmgr_clear-results_args] )) ||
_fwupdmgr_clear-results_args() {
_arguments -C \
'1: :_fwupdmgr_device_ids'
}
(( $+functions[_fwupdmgr_disable-remote_args] )) ||
_fwupdmgr_disable-remote_args() {
_arguments -C \
'1: :_fwupdmgr_remote_ids'
}
(( $+functions[_fwupdmgr_downgrade_args] )) ||
_fwupdmgr_downgrade_args() {
_arguments -C \
'1: :_fwupdmgr_device_ids'
}
(( $+functions[_fwupdmgr_enable-remote_args] )) ||
_fwupdmgr_enable-remote_args() {
_arguments -C \
'1: :_fwupdmgr_remote_ids'
}
(( $+functions[_fwupdmgr_get-approved-firmware_args] )) ||
_fwupdmgr_get-approved-firmware_args() {
_message 'no more arguments' && ret=0
}
(( $+functions[_fwupdmgr_get-details_args] )) ||
_fwupdmgr_get-details_args() {
_files
}
(( $+functions[_fwupdmgr_get-devices_args] )) ||
_fwupdmgr_get-devices_args() {
_message 'no more arguments' && ret=0
}
(( $+functions[_fwupdmgr_get-history_args] )) ||
_fwupdmgr_get-history_args() {
_message 'no more arguments' && ret=0
}
(( $+functions[_fwupdmgr_get-releases_args] )) ||
_fwupdmgr_get-releases_args() {
_arguments -C \
'1: :_fwupdmgr_device_ids'
}
(( $+functions[_fwupdmgr_get-remotes_args] )) ||
_fwupdmgr_get-remotes_args() {
_message 'no more arguments' && ret=0
}
(( $+functions[_fwupdmgr_get-results_args] )) ||
_fwupdmgr_get-results_args() {
_arguments -C \
'1: :_fwupdmgr_device_ids'
}
(( $+functions[_fwupdmgr_get-topology_args] )) ||
_fwupdmgr_get-topology_args() {
_message 'no more arguments' && ret=0
}
(( $+functions[_fwupdmgr_get-updates_args] )) ||
_fwupdmgr_get-updates_args() {
_message 'no more arguments' && ret=0
}
(( $+functions[_fwupdmgr_install_args] )) ||
_fwupdmgr_install_args() {
_arguments -C \
'1: :_files' \
'2: :_fwupdmgr_device_ids'
}
(( $+functions[_fwupdmgr_TODO_args] )) ||
_fwupdmgr_TODO_args() {
_message 'no more arguments' && ret=0
}
(( $+functions[_fwupdmgr_modify-config_args] )) ||
_fwupdmgr_modify-config_args() {
local ret=1
if compset -P '*,'; then
_wanted config-value expl 'config value' _fwupdmgr_config_values ${IPREFIX%=} && ret=0
else
_wanted config-key expl 'config key' _fwupdmgr_config_keys -qS, && ret=0
fi
return ret
}
(( $+functions[_fwupdmgr_modify-remote_args] )) ||
_fwupdmgr_modify-remote_args() {
_arguments -C \
'1: :_fwupdmgr_remote_ids' \
'2: :_fwupdmgr_remote_keys' \
'3: :_fwupdmgr_remote_values'
}
(( $+functions[_fwupdmgr_refresh_args] )) ||
_fwupdmgr_refresh_args() {
_arguments -C \
'1: :_files' \
'2:file signature:' \
'3: :_fwupdmgr_remote_ids'
}
(( $+functions[_fwupdmgr_report-history_args] )) ||
_fwupdmgr_report-history_args() {
_message 'no more arguments' && ret=0
}
(( $+functions[_fwupdmgr_set-approved-firmware_args] )) ||
_fwupdmgr_set-approved-firmware_args() {
_message 'checksum' && ret=0
}
(( $+functions[_fwupdmgr_unlock_args] )) ||
_fwupdmgr_unlock_args() {
_arguments -C \
'1: :_fwupdmgr_device_ids'
}
(( $+functions[_fwupdmgr_update_args] )) ||
_fwupdmgr_update_args() {
_message 'no more arguments' && ret=0
}
(( $+functions[_fwupdmgr_verify_args] )) ||
_fwupdmgr_verify_args() {
_arguments -C \
'1: :_fwupdmgr_device_ids'
}
(( $+functions[_fwupdmgr_verify-update_args] )) ||
_fwupdmgr_verify-update_args() {
_arguments -C \
'1: :_fwupdmgr_device_ids'
}
(( $+functions[_fwupdmgr_device_ids] )) || (( $+functions[_fwupdmgr_device_ids] )) ||
_fwupdmgr_device_ids() { _fwupdmgr_device_ids() {
# TODO add device name as description # TODO add device name as description
local devices=($(_call_program devices fwupdmgr get-devices | grep -Po 'DeviceId:\s+\K(.*)')) local -a devices
devices=($(_call_program devices fwupdmgr get-devices | awk '/Device ID/||/DeviceId/{print $NF}'))
_describe -t devices 'device ID' devices _describe -t devices 'device ID' devices
} }
(( $+functions[_fwupdmgr_remote_ids] )) || (( $+functions[_fwupdmgr_remote_ids] )) ||
_fwupdmgr_remote_ids() { _fwupdmgr_remote_ids() {
# TODO add remote description # TODO add remote description
local remotes=($(_call_program remotes fwupdmgr get-remotes | grep -Po 'Remote ID:\s+\K(.*)')) local -a remotes
remotes=($(_call_program remotes fwupdmgr get-remotes | awk '/Remote ID/{print $NF}'))
_describe -t remotes 'remote ID' remotes _describe -t remotes 'remote ID' remotes
} }
(( $+functions[_fwupdmgr_checksums] )) ||
_fwupdmgr_checksums() {
_guard '[^\-]#' 'checksum'
}
(( $+functions[_fwupdmgr_config_keys] )) ||
_fwupdmgr_config_keys() {
_guard '[^\-]#' 'config key'
}
(( $+functions[_fwupdmgr_config_values] )) ||
_fwupdmgr_config_values() {
_guard '[^\-]#' 'config value'
}
(( $+functions[_fwupdmgr_remote_keys] )) ||
_fwupdmgr_remote_keys() {
_guard '[^\-]#' 'remote key'
}
(( $+functions[_fwupdmgr_remote_values] )) ||
_fwupdmgr_remote_values() {
_guard '[^\-]#' 'remote value'
}
_fwupdmgr "$@" _fwupdmgr "$@"
# Local Variables: # Local Variables: