chiark / gitweb /
shell-completion: systemd-analyze verify, systemctl link
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 22 Jul 2014 01:11:56 +0000 (21:11 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 22 Jul 2014 02:33:51 +0000 (22:33 -0400)
Some zsh completion helpers were not installed, so completion
was broken.

Add systemd-analyze verify. Make systemctl link complete only
unit names.

Makefile.am
TODO
shell-completion/bash/systemctl.in
shell-completion/bash/systemd-analyze
shell-completion/zsh/_sd_unit_files [new file with mode: 0644]
shell-completion/zsh/_systemctl.in
shell-completion/zsh/_systemd-analyze

index 1cb77b9fbf76f7cb39583f761697aa03a2cb3220..55ed54d941f356ed6f33f257cc0515773d5f6d90 100644 (file)
@@ -407,6 +407,8 @@ dist_zshcompletion_DATA = \
        shell-completion/zsh/_systemd-analyze \
        shell-completion/zsh/_systemd-run \
        shell-completion/zsh/_sd_hosts_or_user_at_host \
+       shell-completion/zsh/_sd_outputmodes \
+       shell-completion/zsh/_sd_unit_files \
        shell-completion/zsh/_systemd-delta \
        shell-completion/zsh/_systemd
 
diff --git a/TODO b/TODO
index 4a1313d419dd63451e377d1494d66f57519a105f..d964b524d709f5008c9dc6db7214824d35f6dd24 100644 (file)
--- a/TODO
+++ b/TODO
@@ -704,6 +704,9 @@ External:
 
 * register catalog database signature as file magic
 
+* zsh shell completion: <command> <verb> -<TAB> should complete options, but currently
+  does not
+
 Regularly:
 
 * look for close() vs. close_nointr() vs. close_nointr_nofail()
index 4beec4e13f96932b3fd6eeac2defdea427927f15..c5950cc75222c43b8b88f1a20bb7a4bb016f3ca9 100644 (file)
@@ -89,7 +89,7 @@ _systemctl () {
                                 comps=$(compgen -A signal)
                         ;;
                         --type|-t)
-                                comps='automount device mount path service snapshot socket swap target timer'
+                                comps='automount busname device mount path service snapshot socket swap target timer'
                         ;;
                         --state)
                                 comps='loaded not-found stub
index 5575bebfc45c1148fedb62bc12676a4d3b6db19e..77d1b542a238efd9669ece79d1b163170544b7d2 100644 (file)
@@ -44,6 +44,7 @@ _systemd_analyze() {
                 [CRITICAL_CHAIN]='critical-chain'
                 [DOT]='dot'
                 [LOG_LEVEL]='set-log-level'
+                [VERIFY]='verify'
         )
 
         _init_completion || return
@@ -99,6 +100,14 @@ _systemd_analyze() {
                         comps='debug info notice warning err crit alert emerg'
                 fi
 
+        elif __contains_word "$verb" ${VERBS[VERIFY]}; then
+                if [[ $cur = -* ]]; then
+                        comps='--help --version --system --user --no-man'
+                else
+                        comps=$( compgen -A file -- "$cur" )
+                        compopt -o filenames
+                fi
+
         fi
 
         COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
diff --git a/shell-completion/zsh/_sd_unit_files b/shell-completion/zsh/_sd_unit_files
new file mode 100644 (file)
index 0000000..4778a04
--- /dev/null
@@ -0,0 +1,9 @@
+#autoload
+
+_sd_unit_files() {
+    local files expl
+    files=( '*:files:->files' )
+
+    _description files expl 'unit file'
+    _files "$expl[@]" -g '*.(automount|busname|device|mount|path|service|snapshot|socket|swap|target|timer)'
+}
index d9b8d1c0e32b27d7938a15592ec898439df8a96e..d364d17dd9004dd256e98fa2862c3857d53021a4 100644 (file)
@@ -261,7 +261,9 @@ for fun in set-environment unset-environment ; do
   }
 done
 
-(( $+functions[_systemctl_link] )) || _systemctl_link() { _files }
+(( $+functions[_systemctl_link] )) || _systemctl_link() {
+   _sd_unit_files
+}
 
 # no systemctl completion for:
 #    [STANDALONE]='daemon-reexec daemon-reload default
@@ -297,7 +299,7 @@ _unit_states() {
 
 _unit_types() {
     local -a _types
-    _types=(automount device mount path service snapshot socket swap target timer)
+    _types=(automount busname device mount path service snapshot socket swap target timer)
     _values -s , "${_types[@]}"
 }
 
index 2eda5fe8a94936d8dfa7a633492364841618d68c..c101ad0fae62293fa1a116dd9f00d700c8f996e2 100644 (file)
@@ -6,6 +6,10 @@ _systemd_analyze_set-log-level() {
     _describe -t level 'logging level' _levels || compadd "$@"
 }
 
+_systemd_analyze_verify() {
+    _sd_unit_files
+}
+
 _systemd_analyze_command(){
     local -a _systemd_analyze_cmds
     # Descriptions taken from systemd-analyze --help.
@@ -17,6 +21,7 @@ _systemd_analyze_command(){
         'dot:Dump dependency graph (in dot(1) format)'
         'dump:Dump server status'
         'set-log-level:Set systemd log threshold'
+        'verify:Check unit files for correctness'
     )
 
     if (( CURRENT == 1 )); then
@@ -38,7 +43,12 @@ _systemd_analyze_command(){
 
 _arguments \
     {-h,--help}'[Show help text.]' \
-    '--user[Shows performance data of user sessions instead of the system manager.]' \
+    '--system[Operate on system systemd instance.]' \
+    '--user[Operate on user systemd instance.]' \
+    '--no-pager[Do not user pager.]' \
+    '--no-man[Do not check man pages.]' \
     '--order[When generating graph for dot, show only order]' \
     '--require[When generating graph for dot, show only requirement]' \
+    {-H+,--host=}'[Operate on remote host]:userathost:_sd_hosts_or_user_at_host' \
+    {-M+,--machine=}'[Operate on local container]:machine' \
     '*::systemd-analyze commands:_systemd_analyze_command'