930e1b8
From 99f96571a3a7667ab6f3a46944c267bcc7c980e6 Mon Sep 17 00:00:00 2001
930e1b8
From: Marko Myllynen <myllynen@redhat.com>
930e1b8
Date: Wed, 13 Nov 2013 23:02:23 -0500
930e1b8
Subject: [PATCH] zsh-completion: add bootctl
930e1b8
930e1b8
---
930e1b8
 Makefile.am                   |  4 ++++
930e1b8
 shell-completion/zsh/_bootctl | 25 +++++++++++++++++++++++++
930e1b8
 2 files changed, 29 insertions(+)
930e1b8
 create mode 100644 shell-completion/zsh/_bootctl
930e1b8
930e1b8
diff --git a/Makefile.am b/Makefile.am
930e1b8
index b4fc33b..efe5aa3 100644
930e1b8
--- a/Makefile.am
930e1b8
+++ b/Makefile.am
930e1b8
@@ -1743,6 +1743,10 @@ bootctl_LDADD = \
930e1b8
 
930e1b8
 bin_PROGRAMS += \
930e1b8
 	bootctl
930e1b8
+
930e1b8
+dist_zshcompletion_DATA += \
930e1b8
+	shell-completion/zsh/_bootctl
930e1b8
+
930e1b8
 endif
930e1b8
 
930e1b8
 # ------------------------------------------------------------------------------
930e1b8
diff --git a/shell-completion/zsh/_bootctl b/shell-completion/zsh/_bootctl
930e1b8
new file mode 100644
930e1b8
index 0000000..7d2453c
930e1b8
--- /dev/null
930e1b8
+++ b/shell-completion/zsh/_bootctl
930e1b8
@@ -0,0 +1,25 @@
930e1b8
+#compdef bootctl
930e1b8
+
930e1b8
+(( $+functions[_bootctl_command] )) || _bootctl_command()
930e1b8
+{
930e1b8
+    local -a _bootctl_cmds
930e1b8
+    _bootctl_cmds=(
930e1b8
+        "status:Show current firmware and boot settings"
930e1b8
+    )
930e1b8
+    if (( CURRENT == 1 )); then
930e1b8
+        _describe -t commands 'bootctl command' _bootctl_cmds || compadd "$@"
930e1b8
+    else
930e1b8
+        local curcontext="$curcontext"
930e1b8
+        cmd="${${_bootctl_cmds[(r)$words[1]:*]%%:*}}"
930e1b8
+        if (( $+functions[_bootctl_$cmd] )); then
930e1b8
+            _bootctl_$cmd
930e1b8
+        else
930e1b8
+            _message "no more options"
930e1b8
+        fi
930e1b8
+    fi
930e1b8
+}
930e1b8
+
930e1b8
+_arguments \
930e1b8
+    {-h,--help}'[Prints a short help text and exits.]' \
930e1b8
+    '--version[Prints a short version string and exits.]' \
930e1b8
+    '*::bootctl command:_bootctl_command'