From 3e512ddebb676f25f8caa1d52fc68b394b5e2775 Mon Sep 17 00:00:00 2001 From: Leonardo da Cunha Date: Wed, 19 Feb 2025 14:37:34 -0800 Subject: [PATCH] completions: Added fdp feature auto-completion. Fixed syntax error on zsh auto-completion Signed-off-by: Leonardo da Cunha --- completions/_nvme | 38 ++++++++++++++++++++++++++++- completions/bash-nvme-completion.sh | 37 ++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 1 deletion(-) diff --git a/completions/_nvme b/completions/_nvme index 324b070e..605e4522 100644 --- a/completions/_nvme +++ b/completions/_nvme @@ -118,6 +118,7 @@ _nvme () { 'version:show the program version' 'ocp:OCP cloud SSD extensions' 'solidigm:Solidigm plug-in extensions' + 'fdp:FDP plug-in extensions' 'micron:Micron plug-in extensions' 'dapustor:DapuStor plug-in extensions' 'help:print brief descriptions of all nvme commands' @@ -603,6 +604,28 @@ _nvme () { ;; esac ;; + (fdp) + case ${words[2]} in + (feature) + local _feature + _feature=( + --endgrp-id=':Endurance group ID' + -e':alias for --endgrp-id' + --enable-conf-idx=':FDP configuration index to enable' + -c':alias for --enable-conf-idx' + --disable=':Disable current FDP configuration' + -d':alias for --disable' + --verbose=':Increase output verbosity' + -v':alias for --verbose' + ) + _arguments '*:: :->subcmds' + _describe -t commands "nvme fdp feature options" _feature + ;; + (*) + _files + ;; + esac + ;; (dapustor) case ${words[2]} in (smart-log-add) @@ -2643,7 +2666,10 @@ _nvme () { -v':alias for --verbose' --output-format=':Output format: normal|json|binary' -o ':alias for --output-format' + ) + _arguments '*:: :->subcmds' _describe -t commands "nvme rotational-media-info-log" _rmi_log + ;; (changed-alloc-ns-list-log) local _changed_alloc_ns_list_log _changed_alloc_ns_list_log=( @@ -2768,6 +2794,16 @@ _nvme () { _arguments '*:: :->subcmds' _describe -t commands "nvme solidigm options" _solidigm ;; + (fdp) + local _fdp + _fdp=( + feature':Show, enable or disable FDP configuration' + version':Shows the plug-in version' + help':Display this help' + ) + _arguments '*:: :->subcmds' + _describe -t commands "nvme fdp options" _fdp + ;; (micron) local micron _micron=( @@ -2824,7 +2860,7 @@ _nvme () { subsystem-reset ns-rescan get-lba-status dsm discover connect-all connect dim disconnect disconnect-all gen-hostnqn show-hostnqn tls-key dir-receive dir-send virt-mgmt rpmb version ocp solidigm dapustor mgmt-addr-list-log - rotational-media-info-log changed-alloc-ns-list-log + rotational-media-info-log changed-alloc-ns-list-log fdp ) _arguments '*:: :->subcmds' _describe -t commands "help: infos on a specific nvme command, or provide no option to see a synopsis of all nvme commands" _h diff --git a/completions/bash-nvme-completion.sh b/completions/bash-nvme-completion.sh index 949f4da5..c2045a7c 100644 --- a/completions/bash-nvme-completion.sh +++ b/completions/bash-nvme-completion.sh @@ -1236,6 +1236,41 @@ plugin_solidigm_opts () { return 0 } +plugin_fdp_opts () { + local opts="" + local compargs="" + + local nonopt_args=0 + for (( i=0; i < ${#words[@]}-1; i++ )); do + if [[ ${words[i]} != -* ]]; then + let nonopt_args+=1 + fi + done + + if [ $nonopt_args -eq 3 ]; then + opts="/dev/nvme* " + fi + + opts+=" " + + case "$1" in + "feature") + opts+=" --endgrp-id= -e --enable-conf-idx= -c \ + --disable -d --verbose -v" + ;; + "version") + opts+=$NO_OPTS + ;; + "help") + opts+=$NO_OPTS + ;; + esac + + COMPREPLY+=( $( compgen $compargs -W "$opts" -- $cur ) ) + + return 0 +} + plugin_transcend_opts () { local opts="" local compargs="" @@ -1631,6 +1666,7 @@ _nvme_subcmds () { clear-fw-activate-history vs-fw-activate-history log-page-directory \ vs-drive-info cloud-SSDplugin-version market-log \ smart-log-add temp-stats workload-tracker version help" + [fdp]="feature version help" [transcend]="healthvalue badblock" [dapustor]="smart-log-add" [zns]="id-ctrl id-ns zone-mgmt-recv \ @@ -1667,6 +1703,7 @@ _nvme_subcmds () { [dera]="plugin_dera_opts" [sfx]="plugin_sfx_opts" [solidigm]="plugin_solidigm_opts" + [fdp]="plugin_fdp_opts" [transcend]="plugin_transcend_opts" [dapustor]="plugin_dapustor_opts" [zns]="plugin_zns_opts" -- 2.50.1