summaryrefslogtreecommitdiff
path: root/roles/ws/minet/files/_minet
blob: 8f3e02cac7340b8c6856b60d49ae97a8c3e6b4b6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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):-""}
}