From 46e5e954053cf0bdb33d318c5b9cf44e155da2dd Mon Sep 17 00:00:00 2001 From: Shohei YOSHIDA Date: Sun, 25 Dec 2022 12:52:22 +0900 Subject: [PATCH] Add metrics subcommand completion --- src/_virtualbox | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/src/_virtualbox b/src/_virtualbox index 1971a6f..13c13d1 100644 --- a/src/_virtualbox +++ b/src/_virtualbox @@ -306,7 +306,7 @@ _vboxmanage() { _vboxmanage_debugvm && ret=0 ;; (metrics) - # TODO + _vboxmanage_metrics && ret=0 ;; (natnetwork) _vboxmanage_natnetwork && ret=0 @@ -1204,6 +1204,53 @@ _vboxmanage_debugvm() { return $ret } +(( $+functions[_vboxmanage_metrics] )) || +_vboxmanage_metrics() { + local ret=1 + + _arguments -C \ + '1: :(collect disable enable list query setup)' \ + '*:: :->arg' \ + && ret=0 + + case $state in + (arg) + case $words[1] in + (collect) + _arguments \ + '--detach[Disables the collection of metric data, so no data is output]' \ + '--list[Shows which metrics match the specified filter]' \ + '--period=[Specifies the number of seconds to wait between collecting metric data samples]:sec' \ + '--samples=[Specifies the number of metric data samples to save]' \ + '1: :_vboxmachines' \ + && ret=0 + ;; + (disable) + _arguments \ + '--list[Shows which metrics match the specified filter]' \ + '1: :_vboxmachines' \ + && ret=0 + ;; + (setup) + _arguments \ + '--list[Shows which metrics match the specified filter]' \ + '--period=[Specifies the number of seconds to wait between collecting metric data samples]:sec' \ + '--samples=[Specifies the number of metric data samples to save]' \ + '1: :_vboxmachines' \ + && ret=0 + ;; + (*) + _arguments \ + '1: :_vboxmachines' \ + && ret=0 + ;; + esac + ;; + esac + + return $ret +} + (( $+functions[_vboxmanage_natnetwork] )) || _vboxmanage_natnetwork() { local ret=1