zsh-workers
 help / color / mirror / code / Atom feed
From: Christian Heinrich <christian@gladbachcity.de>
To: zsh-workers@zsh.org
Subject: Re: [PATCH] Add completion for cpupower command
Date: Mon, 08 Aug 2016 21:31:38 +0200	[thread overview]
Message-ID: <1470684698.11074.173.camel@gladbachcity.de> (raw)
In-Reply-To: <20160731110516.GA20521@pileus.org>

[-- 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 --]

      parent reply	other threads:[~2016-08-08 19:39 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-31 11:05 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 [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1470684698.11074.173.camel@gladbachcity.de \
    --to=christian@gladbachcity.de \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).