Skip to contentSkip to conversation

cpupower : Auto-completion for cpupower tool

PATCH In review Abhishek Goel 3 participants 3 messages Dec 5, 2018 CPU power monitoring

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cpupower : Auto-completion for cpupower tool

This script adds support for auto-completion for cpupower tool. Added support for auto-completion of all the eight commands for cpupower tool and their all subsequent sub-commands, wherever possible.

A sample output after applying this script -

root@ubuntu:~# cpupower f<TAB>
root@ubuntu:~# cpupower frequency-<TAB>
frequency-info  frequency-set
root@ubuntu:~# cpupower frequency-set -
-d          --freq      --governor  --min       --related
-f          -g          --max       -r          -u
root@ubuntu:~# cpupower frequency-set -g <TAB>
conservative ondemand performance powersave schedutil userspace
root@ubuntu:~# cpupower frequency-set -f <TAB>
2061000  2194000  2327000  2460000  2593000  2726000  2859000
2094000  2227000  2360000  2493000  2626000  2759000  2892000
2128000  2261000  2394000  2527000  2660000  2793000  2926000
2161000  2294000  2427000  2560000  2693000  2826000  2959000
root@ubuntu:~# cpupower frequency-set -f 206<TAB>
root@ubuntu:~# cpupower frequency-set -f 2061000
---
 tools/power/cpupower/Makefile               |   6 +-
 tools/power/cpupower/cpupower-completion.sh | 128 ++++++++++++++++++++
 2 files changed, 133 insertions(+), 1 deletion(-)
 create mode 100644 tools/power/cpupower/cpupower-completion.sh
tools/power/cpupower/Makefile +5 -1
index 1dd5f4fcf..8c3adac6b 100644
@@ -89,6 +89,7 @@ endif
 localedir ?=	/usr/share/locale
 docdir ?=       /usr/share/doc/packages/cpupower
 confdir ?=      /etc/
+bash_completion_dir ?= /usr/share/bash-completion/completions
 
 # Toolchain: what tools do we use, and what options do they need:
 
@@ -96,7 +97,8 @@ CP = cp -fpR
 INSTALL = /usr/bin/install -c
 INSTALL_PROGRAM = ${INSTALL}
 INSTALL_DATA  = ${INSTALL} -m 644
-INSTALL_SCRIPT = ${INSTALL_PROGRAM}
+#bash completion scripts get sourced and so they should be rw only.
+INSTALL_SCRIPT = ${INSTALL} -m 644
 
 # If you are running a cross compiler, you may want to set this
 # to something more interesting, like "arm-linux-".  If you want
@@ -288,6 +290,8 @@ install-lib:
 install-tools:
 	$(INSTALL) -d $(DESTDIR)${bindir}
 	$(INSTALL_PROGRAM) $(OUTPUT)cpupower $(DESTDIR)${bindir}
+	$(INSTALL) -d $(DESTDIR)${bash_completion_dir}
+	$(INSTALL_SCRIPT) cpupower-completion.sh '$(DESTDIR)${bash_completion_dir}/cpupower'
 
 install-man:
 	$(INSTALL_DATA) -D man/cpupower.1 $(DESTDIR)${mandir}/man1/cpupower.1
tools/power/cpupower/cpupower-completion.sh new file +128 -0

128 lines not on this page · raw message

Signature · 1 line
2.17.1
#1 lore raw
Quoted 6 lines · CET Abhishek Goel

This script adds support for auto-completion for cpupower tool. Added support for auto-completion of all the eight commands for cpupower tool and their all subsequent sub-commands, wherever possible.

From what I see all changes I proposed in a previous review round

with a "not that broad audience" have been addressed.

I already integrated the patch (slightly different, without functional changes) into the latest cpupower sources of our build service and things work out nice.

Shuah: Can you pick this up for next cpupower submission round, please.

Thanks,

Thomas

maintainer
#2 lore raw
Quoted 13 lines · Thomas Renninger
Quoted 6 lines · CET Abhishek Goel

This script adds support for auto-completion for cpupower tool. Added support for auto-completion of all the eight commands for cpupower tool and their all subsequent sub-commands, wherever possible.

From what I see all changes I proposed in a previous review round

with a "not that broad audience" have been addressed.

I already integrated the patch (slightly different, without functional changes) into the latest cpupower sources of our build service and things work out nice.

Quoted 6 lines

Shuah: Can you pick this up for next cpupower submission round, please.

Thanks,

Thomas

Thanks Thomas.

Patch applied to

git.kernel.org/pub/scm/linux/kernel/git/shuah/linux cpupower branch to be included in the next pull request to Rafael.

thanks,
-- Shuah