zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] Add completion for cpupower command
@ 2016-07-31 11:05 Andy Spencer
  2016-08-01  9:46 ` [PATCH] _cpupower: Move to correct subfolder Andy Spencer
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Andy Spencer @ 2016-07-31 11:05 UTC (permalink / raw)
  To: zsh-workers

These are mostly static options with the exception of the frequency-set
arguments for the governor and min/max frequencies, which are pulled
from the output of frequency-info.
---
 Completion/Linux/_cpupower | 102 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 102 insertions(+)
 create mode 100644 Completion/Linux/_cpupower

diff --git a/Completion/Linux/_cpupower b/Completion/Linux/_cpupower
new file mode 100644
index 0000000..406893e
--- /dev/null
+++ b/Completion/Linux/_cpupower
@@ -0,0 +1,102 @@
+#compdef cpupower
+
+local -a ret state cmds args expl context line
+
+_arguments \
+  '(-h --help)'{-h,--help}'[print usage information]' \
+  '(-v --version)'{-v,--version}'[print package name and version]' \
+  ':cmd:->cmds' \
+  '*::arg:->args' && ret=0
+
+case $state in
+  cmds)
+    cmds=(
+      'frequency-info:show current frequency info'
+      'frequency-set:set frequency parameters'
+      'idle-info:show current idle state info'
+      'idle-set:set idle state parameters'
+      'info:show global power parameters'
+      'set:set global power parameters'
+      'monitor:report frequency and idle statistics'
+      'help:print usage information'
+    )
+    _describe cmd cmds && ret=0
+  ;;
+  args)
+    args=( )
+    case ${words[1]} in
+      frequency-info)
+        args+=(
+          '(-e --debug)'{-e,--debug}'[print debug info]'
+          '(-f --freq)'{-f,--freq}'[show current frequency]'
+          '(-w --hwfreq)'{-w,--hwfreq}'[show current hardware frequency]'
+          '(-l --hwlimits)'{-l,--hwlimits}'[show min/max frequency allowed]'
+          '(-d --driver)'{-d,--driver}'[show the kernel driver in use]'
+          '(-p --policy)'{-p,--policy}'[show the current cpufreq policy]'
+          '(-g --governors)'{-g,--governors}'[show available governers]'
+          '(-r --related-cpus)'{-a,--related-cpus}'[show cpus that run at the same frequency]'
+          '(-a --affected-cpus)'{-a,--affected-cpus}'[show software controlled cpus]'
+          '(-s --stats)'{-s,--stats}'[show cpufreq statistics]'
+          '(-y --latency)'{-y,--latency}'[show frequency change latency]'
+          '(-o --proc)'{-o,--proc}'[print old style proc info]'
+          '(-m --human)'{-m,--human}'[use human readable output]'
+          '(-n --no-rounding)'{-n,--no-rounding}'[disable rounding of values]'
+        )
+        ;;
+      frequency-set)
+        args+=(
+          '(-d --min)'{-d,--min}'[new minimum frequency]:freq:->freq'
+          '(-u --max)'{-u,--max}'[new maximum frequency]:freq:->freq'
+          '(-g --governor)'{-g,--governor}'[new cpufreq governor]:gov:->gov'
+          '(-f --freq)'{-f,--freq}'[new frequency for userspace governor]:freq->freq'
+          '(-r --related)'{-r,--related}'[modify all hardware related cpus]'
+        )
+        ;;
+      idle-info)
+        args+=(
+          '(-f --silent)'{-f,--silent}'[print summary only]'
+          '(-e --proc)'{-e,--proc}'[print old style proc info]'
+        )
+        ;;
+      idle-set)
+        args+=(
+          '(-d --disable)'{-d,--disable}'[disable specific sleep state]:stateno'
+          '(-e --enable)'{-e,--enable}'[enable specific sleep state]:stateno'
+          '(-D --disable-by-latency)'{-D,--disable-by-latency}'[disable state based on latency]:latency'
+          '(-E --enable-all)'{-E,--enable-all}'[enable all idle states]'
+        )
+        ;;
+      info)
+        args+=(
+          '(-b --perf-bias)'{-b,--perf-bias}'[show intel performance bias value]'
+        )
+        ;;
+      set)
+        args+=(
+          '(-b --perf-bias)'{-b,--perf-bias}'[set intel performance bias value]:pbias'
+        )
+        ;;
+      monitor)
+        args+=(
+          '-l[list available monitors]'
+          '-m[display the given monitors]:mon'
+          '-i[mesurement interval]:secs'
+          '-c[schedule on every core]'
+          '-v[increase verbosity]'
+        )
+        ;;
+    esac
+    _arguments "${args[@]}" && ret=0
+    case $state in
+      freq)
+	compadd $(cpupower frequency-info |
+		sed -n 's/ //g; s/,/ /g; s/availablefrequencysteps://p')
+        ;;
+      gov)
+        compadd $(cpupower frequency-info -g | sed 1d)
+        ;;
+    esac
+    ;;
+esac
+
+return ret
-- 
2.7.3


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] _cpupower: Move to correct subfolder
  2016-07-31 11:05 [PATCH] Add completion for cpupower command Andy Spencer
@ 2016-08-01  9:46 ` Andy Spencer
  2016-08-01 20:19 ` [PATCH] Add completion for cpupower command Oliver Kiddle
  2016-08-08 19:31 ` Christian Heinrich
  2 siblings, 0 replies; 6+ messages in thread
From: Andy Spencer @ 2016-08-01  9:46 UTC (permalink / raw)
  To: zsh-workers

---
Oops, looks like I got the wrong folder for this and it should be in
Completion/Linux/Command/_cpupower and not Completion/Linux/_cpupower.

Sorry for the trouble!

 Completion/Linux/{ => Command}/_cpupower | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 rename Completion/Linux/{ => Command}/_cpupower (100%)

diff --git a/Completion/Linux/_cpupower b/Completion/Linux/Command/_cpupower
similarity index 100%
rename from Completion/Linux/_cpupower
rename to Completion/Linux/Command/_cpupower
-- 
2.7.3


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Add completion for cpupower command
  2016-07-31 11:05 [PATCH] Add completion for cpupower command Andy Spencer
  2016-08-01  9:46 ` [PATCH] _cpupower: Move to correct subfolder Andy Spencer
@ 2016-08-01 20:19 ` Oliver Kiddle
  2016-08-01 21:41   ` Daniel Shahaf
  2016-09-21 20:10   ` Oliver Kiddle
  2016-08-08 19:31 ` Christian Heinrich
  2 siblings, 2 replies; 6+ messages in thread
From: Oliver Kiddle @ 2016-08-01 20:19 UTC (permalink / raw)
  To: Andy Spencer; +Cc: zsh-workers

Andy Spencer wrote:
> These are mostly static options with the exception of the frequency-set
> arguments for the governor and min/max frequencies, which are pulled
> from the output of frequency-info.

Thanks for contributing this. I've taken a look and have a few comments.
Mostly all minor points.

> +#compdef cpupower
> +
> +local -a ret state cmds args expl context line

ret should be initialised to 1 and shouldn't be of array type.

In this function, I'd recommand having _arguments update $curcontext
instead of using the context array. So pass -C to _arguments and use:
  local curcontext="$curcontext"

The array form with $context is only necessary if more than one state
is simultaneously possible. That happens when you have optional
arguments which cpupower doesn't.

> +
> +_arguments \
> +  '(-h --help)'{-h,--help}'[print usage information]' \
> +  '(-v --version)'{-v,--version}'[print package name and version]' \

As is often the case with version and help options, no other options are
valid following them. So these two exclusion lists can be reduced to
(- :)
e.g:
  '(- :)'{-h,--help}'[print usage information]'

Also, doesn't cpupower also have a -c/--cpu option for selecting
specific CPUs and -d/--debug?

> +  ':cmd:->cmds' \
> +  '*::arg:->args' && ret=0
> +
> +case $state in
> +  cmds)

It'd also be useful to complete these commands after the help command
but this doesn't do that.

> +  args)
> +    args=( )
> +    case ${words[1]} in

With commands that take subcommands, it is common practice to insert the
subcommand in to the command component of $curcontext at this point.
Something like:
  curcontext="${curcontext%:*}-$words[1]:"

> +      frequency-info)
> +        args+=(
> +          '(-e --debug)'{-e,--debug}'[print debug info]'
> +          '(-f --freq)'{-f,--freq}'[show current frequency]'
> +          '(-w --hwfreq)'{-w,--hwfreq}'[show current hardware frequency]'
> +          '(-l --hwlimits)'{-l,--hwlimits}'[show min/max frequency allowed]'
> +          '(-d --driver)'{-d,--driver}'[show the kernel driver in use]'
> +          '(-p --policy)'{-p,--policy}'[show the current cpufreq policy]'
> +          '(-g --governors)'{-g,--governors}'[show available governers]'
> +          '(-r --related-cpus)'{-a,--related-cpus}'[show cpus that run at the same frequency]'
> +          '(-a --affected-cpus)'{-a,--affected-cpus}'[show software controlled cpus]'
> +          '(-s --stats)'{-s,--stats}'[show cpufreq statistics]'
> +          '(-y --latency)'{-y,--latency}'[show frequency change latency]'
> +          '(-o --proc)'{-o,--proc}'[print old style proc info]'
> +          '(-m --human)'{-m,--human}'[use human readable output]'
> +          '(-n --no-rounding)'{-n,--no-rounding}'[disable rounding of values]'
> +        )

The exclusion lists could be a lot more restrictive. Most combinations
print:
  You can't specify more than one --cpu parameter and/or
  more than one output-specific argument
I think it is perhaps only the last three options that can be used with others.

> +      frequency-set)

> +          '(-f --freq)'{-f,--freq}'[new frequency for userspace governor]:freq->freq'

There's a colon missing on that line.


> +        args+=(
> +          '(-d --disable)'{-d,--disable}'[disable specific sleep state]:stateno'
> +          '(-e --enable)'{-e,--enable}'[enable specific sleep state]:stateno'

Not especially important but it's not possible to complete those
states is it? Documentation points to
/sys/devices/system/cpu/cpu*/cpuidle/state*. Those don't exist on
my system but that might be because it's very old.

> +      monitor)

> +          '-i[mesurement interval]:secs'

measurement

> +    _arguments "${args[@]}" && ret=0

You can pass -s to this _arguments as it seems cpupower lets you clump
together options, e.g. cpupower frequency-info -fn

> +    case $state in
> +      freq)
> +	compadd $(cpupower frequency-info |
> +		sed -n 's/ //g; s/,/ /g; s/availablefrequencysteps://p')

It'd be nice to have descriptions for this and the governors. e.g.:
  _wanted frequencies expl frequency compadd ....
And if you stick to the context array and no -C option to _arguments,
this would need to be:
   _wanted -C "$context" frequencies ...

Oliver


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Add completion for cpupower command
  2016-08-01 20:19 ` [PATCH] Add completion for cpupower command Oliver Kiddle
@ 2016-08-01 21:41   ` Daniel Shahaf
  2016-09-21 20:10   ` Oliver Kiddle
  1 sibling, 0 replies; 6+ messages in thread
From: Daniel Shahaf @ 2016-08-01 21:41 UTC (permalink / raw)
  To: Oliver Kiddle; +Cc: Andy Spencer, zsh-workers

Oliver Kiddle wrote on Mon, Aug 01, 2016 at 22:19:35 +0200:
> Andy Spencer wrote:
> > +          '(-f --freq)'{-f,--freq}'[new frequency for userspace governor]:freq->freq'
> 
> There's a colon missing on that line.

Should it be {-f+,--freq=}?  That is, can the argument be in the same
word as the option?

The part after the first colon is in this function abbreviated ("freq",
"secs", etc); don't we usually prefer full noun phrases ("frequency",
"interval (seconds)", etc)?

Oliver's review addresses all the other points I noticed (and a few that
I didn't).

Cheers,

Daniel


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Add completion for cpupower command
  2016-07-31 11:05 [PATCH] Add completion for cpupower command Andy Spencer
  2016-08-01  9:46 ` [PATCH] _cpupower: Move to correct subfolder Andy Spencer
  2016-08-01 20:19 ` [PATCH] Add completion for cpupower command Oliver Kiddle
@ 2016-08-08 19:31 ` Christian Heinrich
  2 siblings, 0 replies; 6+ messages in thread
From: Christian Heinrich @ 2016-08-08 19:31 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 5739 bytes --]

Hi,

thanks for your contribution!

I'm still on ZSH 5.2 and didn't try the last development version of
ZSH, but I can't see why this shouldn't work with my version.

Something that I found was that

% cpupower frequency-set -g <tab>

yields as options:

> available    cpufreq      governors:   performance  powersave 

i.e., I can select "available", "cpufreq", ... as options. This seems
to be a bug. I'm using cpupower 4.6 on Debian Testing.


Best
Christian
On Sun, 2016-07-31 at 11:05 +0000, Andy Spencer wrote:
> These are mostly static options with the exception of the frequency-
> set
> arguments for the governor and min/max frequencies, which are pulled
> from the output of frequency-info.
> ---
>  Completion/Linux/_cpupower | 102
> +++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 102 insertions(+)
>  create mode 100644 Completion/Linux/_cpupower
> 
> diff --git a/Completion/Linux/_cpupower b/Completion/Linux/_cpupower
> new file mode 100644
> index 0000000..406893e
> --- /dev/null
> +++ b/Completion/Linux/_cpupower
> @@ -0,0 +1,102 @@
> +#compdef cpupower
> +
> +local -a ret state cmds args expl context line
> +
> +_arguments \
> +  '(-h --help)'{-h,--help}'[print usage information]' \
> +  '(-v --version)'{-v,--version}'[print package name and version]' \
> +  ':cmd:->cmds' \
> +  '*::arg:->args' && ret=0
> +
> +case $state in
> +  cmds)
> +    cmds=(
> +      'frequency-info:show current frequency info'
> +      'frequency-set:set frequency parameters'
> +      'idle-info:show current idle state info'
> +      'idle-set:set idle state parameters'
> +      'info:show global power parameters'
> +      'set:set global power parameters'
> +      'monitor:report frequency and idle statistics'
> +      'help:print usage information'
> +    )
> +    _describe cmd cmds && ret=0
> +  ;;
> +  args)
> +    args=( )
> +    case ${words[1]} in
> +      frequency-info)
> +        args+=(
> +          '(-e --debug)'{-e,--debug}'[print debug info]'
> +          '(-f --freq)'{-f,--freq}'[show current frequency]'
> +          '(-w --hwfreq)'{-w,--hwfreq}'[show current hardware
> frequency]'
> +          '(-l --hwlimits)'{-l,--hwlimits}'[show min/max frequency
> allowed]'
> +          '(-d --driver)'{-d,--driver}'[show the kernel driver in
> use]'
> +          '(-p --policy)'{-p,--policy}'[show the current cpufreq
> policy]'
> +          '(-g --governors)'{-g,--governors}'[show available
> governers]'
> +          '(-r --related-cpus)'{-a,--related-cpus}'[show cpus that
> run at the same frequency]'
> +          '(-a --affected-cpus)'{-a,--affected-cpus}'[show software
> controlled cpus]'
> +          '(-s --stats)'{-s,--stats}'[show cpufreq statistics]'
> +          '(-y --latency)'{-y,--latency}'[show frequency change
> latency]'
> +          '(-o --proc)'{-o,--proc}'[print old style proc info]'
> +          '(-m --human)'{-m,--human}'[use human readable output]'
> +          '(-n --no-rounding)'{-n,--no-rounding}'[disable rounding
> of values]'
> +        )
> +        ;;
> +      frequency-set)
> +        args+=(
> +          '(-d --min)'{-d,--min}'[new minimum frequency]:freq:-
> >freq'
> +          '(-u --max)'{-u,--max}'[new maximum frequency]:freq:-
> >freq'
> +          '(-g --governor)'{-g,--governor}'[new cpufreq
> governor]:gov:->gov'
> +          '(-f --freq)'{-f,--freq}'[new frequency for userspace
> governor]:freq->freq'
> +          '(-r --related)'{-r,--related}'[modify all hardware
> related cpus]'
> +        )
> +        ;;
> +      idle-info)
> +        args+=(
> +          '(-f --silent)'{-f,--silent}'[print summary only]'
> +          '(-e --proc)'{-e,--proc}'[print old style proc info]'
> +        )
> +        ;;
> +      idle-set)
> +        args+=(
> +          '(-d --disable)'{-d,--disable}'[disable specific sleep
> state]:stateno'
> +          '(-e --enable)'{-e,--enable}'[enable specific sleep
> state]:stateno'
> +          '(-D --disable-by-latency)'{-D,--disable-by-
> latency}'[disable state based on latency]:latency'
> +          '(-E --enable-all)'{-E,--enable-all}'[enable all idle
> states]'
> +        )
> +        ;;
> +      info)
> +        args+=(
> +          '(-b --perf-bias)'{-b,--perf-bias}'[show intel performance
> bias value]'
> +        )
> +        ;;
> +      set)
> +        args+=(
> +          '(-b --perf-bias)'{-b,--perf-bias}'[set intel performance
> bias value]:pbias'
> +        )
> +        ;;
> +      monitor)
> +        args+=(
> +          '-l[list available monitors]'
> +          '-m[display the given monitors]:mon'
> +          '-i[mesurement interval]:secs'
> +          '-c[schedule on every core]'
> +          '-v[increase verbosity]'
> +        )
> +        ;;
> +    esac
> +    _arguments "${args[@]}" && ret=0
> +    case $state in
> +      freq)
> +	compadd $(cpupower frequency-info |
> +		sed -n 's/ //g; s/,/ /g;
> s/availablefrequencysteps://p')
> +        ;;
> +      gov)
> +        compadd $(cpupower frequency-info -g | sed 1d)
> +        ;;
> +    esac
> +    ;;
> +esac
> +
> +return ret

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Add completion for cpupower command
  2016-08-01 20:19 ` [PATCH] Add completion for cpupower command Oliver Kiddle
  2016-08-01 21:41   ` Daniel Shahaf
@ 2016-09-21 20:10   ` Oliver Kiddle
  1 sibling, 0 replies; 6+ messages in thread
From: Oliver Kiddle @ 2016-09-21 20:10 UTC (permalink / raw)
  To: zsh-workers; +Cc: Andy Spencer

On 1 Aug, I wrote:
> Thanks for contributing this. I've taken a look and have a few comments.
> Mostly all minor points.

Following patch implements these comments. I've left the frequency
steps alone: it doesn't work on any system I've tried it on but
that's probably because my hardware doesn't support it. Newer
versions of cpupower list governors in a slightly different format,
hence the issue Christian reported. This should now work with both
the older format and the newer (at least up to version 4.8).

Oliver

diff --git a/Completion/Linux/Command/_cpupower b/Completion/Linux/Command/_cpupower
index 406893e..6713323 100644
--- a/Completion/Linux/Command/_cpupower
+++ b/Completion/Linux/Command/_cpupower
@@ -1,102 +1,119 @@
 #compdef cpupower
 
-local -a ret state cmds args expl context line
+local curcontext="$curcontext" ret=1
+local -a state line expl cmds args
+typeset -A opt_args
 
-_arguments \
-  '(-h --help)'{-h,--help}'[print usage information]' \
-  '(-v --version)'{-v,--version}'[print package name and version]' \
+_arguments -C \
+  '(- :)'{-h,--help}'[print help information]' \
+  '(- :)'{-v,--version}'[print version information]' \
+  '(-d --debug)'{-d,--debug}'[enable debug output]' \
+  '(-c --cpu)'{-c,--cpu}'[limit values to specific processor cores]:cpu' \
   ':cmd:->cmds' \
   '*::arg:->args' && ret=0
 
+cmds=(
+  'frequency-info:show current frequency info'
+  'frequency-set:set frequency parameters'
+  'idle-info:show current idle state info'
+  'idle-set:set idle state parameters'
+  'info:show global power parameters'
+  'set:set global power parameters'
+  'monitor:report frequency and idle statistics'
+  'help:print usage information'
+)
 case $state in
   cmds)
-    cmds=(
-      'frequency-info:show current frequency info'
-      'frequency-set:set frequency parameters'
-      'idle-info:show current idle state info'
-      'idle-set:set idle state parameters'
-      'info:show global power parameters'
-      'set:set global power parameters'
-      'monitor:report frequency and idle statistics'
-      'help:print usage information'
-    )
-    _describe cmd cmds && ret=0
+    _describe command cmds && ret=0
   ;;
   args)
-    args=( )
+    curcontext="${curcontext%:*}-$words[1]"
     case ${words[1]} in
+      help)
+        _describe command cmds
+        return
+      ;;
       frequency-info)
-        args+=(
-          '(-e --debug)'{-e,--debug}'[print debug info]'
-          '(-f --freq)'{-f,--freq}'[show current frequency]'
-          '(-w --hwfreq)'{-w,--hwfreq}'[show current hardware frequency]'
-          '(-l --hwlimits)'{-l,--hwlimits}'[show min/max frequency allowed]'
-          '(-d --driver)'{-d,--driver}'[show the kernel driver in use]'
-          '(-p --policy)'{-p,--policy}'[show the current cpufreq policy]'
-          '(-g --governors)'{-g,--governors}'[show available governers]'
-          '(-r --related-cpus)'{-a,--related-cpus}'[show cpus that run at the same frequency]'
-          '(-a --affected-cpus)'{-a,--affected-cpus}'[show software controlled cpus]'
-          '(-s --stats)'{-s,--stats}'[show cpufreq statistics]'
-          '(-y --latency)'{-y,--latency}'[show frequency change latency]'
-          '(-o --proc)'{-o,--proc}'[print old style proc info]'
+        args=(
           '(-m --human)'{-m,--human}'[use human readable output]'
           '(-n --no-rounding)'{-n,--no-rounding}'[disable rounding of values]'
+          - '(info)'
+          {-e,--debug}'[print debug info]'
+          {-f,--freq}'[show current frequency]'
+          {-w,--hwfreq}'[show current hardware frequency]'
+          {-l,--hwlimits}'[show min/max frequency allowed]'
+          {-d,--driver}'[show the kernel driver in use]'
+          {-p,--policy}'[show the current cpufreq policy]'
+          {-g,--governors}'[show available governers]'
+          {-r,--related-cpus}'[show cpus that run at the same frequency]'
+          {-a,--affected-cpus}'[show software controlled cpus]'
+          {-s,--stats}'[show cpufreq statistics]'
+          {-y,--latency}'[show frequency change latency]'
         )
-        ;;
+        [[ -n $opt_args[(i)-(c|-cpu)] ]] || args+=(
+          {-o,--proc}'[print old style proc info]'
+        )
+      ;;
       frequency-set)
-        args+=(
-          '(-d --min)'{-d,--min}'[new minimum frequency]:freq:->freq'
-          '(-u --max)'{-u,--max}'[new maximum frequency]:freq:->freq'
-          '(-g --governor)'{-g,--governor}'[new cpufreq governor]:gov:->gov'
-          '(-f --freq)'{-f,--freq}'[new frequency for userspace governor]:freq->freq'
+        args=(
+          '(-d --min)'{-d+,--min}'[new minimum frequency]:frequency:->frequencies'
+          '(-u --max)'{-u+,--max}'[new maximum frequency]:frequency:->frequencies'
+          '(-g --governor)'{-g+,--governor}'[new cpufreq governor]:governor:->governors'
+          '(-)'{-f+,--freq}'[new frequency for userspace governor]:frequency:->frequencies'
           '(-r --related)'{-r,--related}'[modify all hardware related cpus]'
         )
-        ;;
+      ;;
       idle-info)
-        args+=(
+        args=(
           '(-f --silent)'{-f,--silent}'[print summary only]'
-          '(-e --proc)'{-e,--proc}'[print old style proc info]'
+          '(-e --proc)'{-e,--proc}'[print old style proc info (deprecated)]'
         )
-        ;;
+      ;;
       idle-set)
-        args+=(
-          '(-d --disable)'{-d,--disable}'[disable specific sleep state]:stateno'
-          '(-e --enable)'{-e,--enable}'[enable specific sleep state]:stateno'
-          '(-D --disable-by-latency)'{-D,--disable-by-latency}'[disable state based on latency]:latency'
+        args=(
+          '(-d --disable)'{-d+,--disable}'[disable specific sleep state]:state no'
+          '(-e --enable)'{-e+,--enable}'[enable specific sleep state]:state no'
+          '(-D --disable-by-latency)'{-D+,--disable-by-latency}'[disable state based on latency]:latency'
           '(-E --enable-all)'{-E,--enable-all}'[enable all idle states]'
         )
-        ;;
+      ;;
       info)
-        args+=(
+        args=(
           '(-b --perf-bias)'{-b,--perf-bias}'[show intel performance bias value]'
         )
-        ;;
+      ;;
       set)
-        args+=(
-          '(-b --perf-bias)'{-b,--perf-bias}'[set intel performance bias value]:pbias'
+        args=(
+          '(-b --perf-bias)'{-b+,--perf-bias}'[set intel performance bias value]:performance bias'
         )
-        ;;
+      ;;
       monitor)
-        args+=(
-          '-l[list available monitors]'
-          '-m[display the given monitors]:mon'
-          '-i[mesurement interval]:secs'
+        args=(
+          '(-)-l[list available monitors]'
+          '-m+[display specified monitors]:monitor:->monitors'
+          '-i+[measurement interval]:interval (seconds)'
           '-c[schedule on every core]'
           '-v[increase verbosity]'
+          '*:::command: _normal'
         )
-        ;;
+      ;;
     esac
-    _arguments "${args[@]}" && ret=0
+    _arguments -C -s "$args[@]" && ret=0
     case $state in
-      freq)
-	compadd $(cpupower frequency-info |
-		sed -n 's/ //g; s/,/ /g; s/availablefrequencysteps://p')
-        ;;
-      gov)
-        compadd $(cpupower frequency-info -g | sed 1d)
-        ;;
+      frequencies)
+        _wanted -x frequencies expl frequency compadd $(cpupower frequency-info |
+               sed -n 's/ //g; s/,/ /g; s/availablefrequencysteps://p') && ret=0
+      ;;
+      governors)
+        _wanted governors expl 'scaling governor' compadd \
+            ${=${"$(_call_program governors cpupower frequency-info -g)"}##*:} && ret=0
+      ;;
+      monitors)
+        _sequence _wanted monitors expl 'monitor' compadd - ${${${(M)${(f)"$(_call_program monitors \
+            cpupower monitor -l)"}:#Monitor *}#*\"}%%\"*} && ret=0
+      ;;
     esac
-    ;;
+  ;;
 esac
 
 return ret


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-09-21 20:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-31 11:05 [PATCH] Add completion for cpupower command Andy Spencer
2016-08-01  9:46 ` [PATCH] _cpupower: Move to correct subfolder Andy Spencer
2016-08-01 20:19 ` [PATCH] Add completion for cpupower command Oliver Kiddle
2016-08-01 21:41   ` Daniel Shahaf
2016-09-21 20:10   ` Oliver Kiddle
2016-08-08 19:31 ` Christian Heinrich

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).