From 681f88d28fb3f1230f18bbdac23f75a9e62bd1b7 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Mon, 28 Dec 2020 21:29:49 +0100 Subject: ws/minet: initial version --- roles/ws/minet/files/_minet | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 roles/ws/minet/files/_minet (limited to 'roles/ws/minet/files/_minet') 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):-""} +} -- cgit v1.2.3