chiark / gitweb /
zsh-completion: add bootctl
authorMarko Myllynen <myllynen@redhat.com>
Thu, 14 Nov 2013 04:02:23 +0000 (23:02 -0500)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 14 Nov 2013 04:02:23 +0000 (23:02 -0500)
Makefile.am
shell-completion/zsh/_bootctl [new file with mode: 0644]

index 789ca026b0fdc08c41f43051ef36857017a576c8..558aa1bf0fcb1fe0ca2c32d6083f57835e7621d1 100644 (file)
@@ -1730,6 +1730,10 @@ bootctl_LDADD = \
 
 bin_PROGRAMS += \
        bootctl
+
+dist_zshcompletion_DATA += \
+       shell-completion/zsh/_bootctl
+
 endif
 
 # ------------------------------------------------------------------------------
diff --git a/shell-completion/zsh/_bootctl b/shell-completion/zsh/_bootctl
new file mode 100644 (file)
index 0000000..7d2453c
--- /dev/null
@@ -0,0 +1,25 @@
+#compdef bootctl
+
+(( $+functions[_bootctl_command] )) || _bootctl_command()
+{
+    local -a _bootctl_cmds
+    _bootctl_cmds=(
+        "status:Show current firmware and boot settings"
+    )
+    if (( CURRENT == 1 )); then
+        _describe -t commands 'bootctl command' _bootctl_cmds || compadd "$@"
+    else
+        local curcontext="$curcontext"
+        cmd="${${_bootctl_cmds[(r)$words[1]:*]%%:*}}"
+        if (( $+functions[_bootctl_$cmd] )); then
+            _bootctl_$cmd
+        else
+            _message "no more options"
+        fi
+    fi
+}
+
+_arguments \
+    {-h,--help}'[Prints a short help text and exits.]' \
+    '--version[Prints a short version string and exits.]' \
+    '*::bootctl command:_bootctl_command'