summaryrefslogtreecommitdiff
path: root/roles/ws/minet/files/_minet
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2020-12-28 21:29:49 +0100
committerChristian Pointner <equinox@spreadspace.org>2020-12-28 21:29:49 +0100
commit681f88d28fb3f1230f18bbdac23f75a9e62bd1b7 (patch)
tree0bb67d7144ca8785e0f06c30e7b1a6edf27e3907 /roles/ws/minet/files/_minet
parentadd host ch-equinox-t450s (diff)
ws/minet: initial version
Diffstat (limited to 'roles/ws/minet/files/_minet')
-rw-r--r--roles/ws/minet/files/_minet40
1 files changed, 40 insertions, 0 deletions
diff --git a/roles/ws/minet/files/_minet b/roles/ws/minet/files/_minet
new file mode 100644
index 00000000..8f3e02ca
--- /dev/null
+++ b/roles/ws/minet/files/_minet
@@ -0,0 +1,40 @@
+#compdef _minet minet
+#autoload
+
+
+_minet () {
+ local cmd
+ if (( CURRENT > 2)); then
+ cmd=${words[2]}
+ # Set the context for the subcommand.
+ curcontext="${curcontext%:*:*}:pass-$cmd"
+ # Narrow the range of words we are looking at to exclude `pass'
+ (( CURRENT-- ))
+ shift words
+ # Run the completion for the subcommand
+ case "${cmd}" in
+ start)
+ if (( CURRENT == 2 )); then
+ _minet_complete_entries
+ fi
+ ;;
+ esac
+ else
+ local -a subcommands
+ subcommands=(
+ "start:Connect to network"
+ "stop:Disconnect from network"
+ "restart:Reconnect to network"
+ "suspend:Suspend current connection"
+ "resume:Resume suspended connection"
+ "status:Print connection status"
+ )
+ _describe -t commands 'minet' subcommands
+ fi
+}
+
+_minet_complete_entries () {
+ local IFS=$'\n'
+ local prefix="/usr/local/lib/minet"
+ _values -C 'connections' ${$(find -L "$prefix" \( -name minet_helpers.sh -o -name template \) -prune -o -type f -executable -print 2>/dev/null | sed -e "s#${prefix}/\{0,1\}##" | sort):-""}
+}