aboutsummaryrefslogtreecommitdiff
blob: 0b04df545749186179ddcc8a2e5139de80b54630 (plain)
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# -*-eselect-*-  vim: ft=eselect
# Copyright 2005-2013 Gentoo Foundation
# Distributed under the terms of the GNU GPL version 2 or later

DESCRIPTION="Do things to a cow"
MAINTAINER="eselect@gentoo.org"

### moo action

describe_moo() {
	echo "Say moo"
}

describe_moo_parameters() {
	echo "<text>"
}

describe_moo_options() {
	echo "text : Text to display (optional)"
	echo "--dead : Use a dead cow"
	echo "--borg : Use a borged cow"
}

do_moo() {
	local params=
	while [[ ${1#--} != ${1} ]] ; do
		if [[ "--dead" == ${1} ]] ; then
			shift
			params="${params} -d"
		elif [[ "--borg" == "${1}" ]] ; then
			shift
			params="${params} -b"
		elif [[ "--" == "${1}" ]] ; then
			break
		else
			die -q "Unknown parameter ${1}"
		fi
	done

	echo "${@:-I am a cow}" | cowsay ${params}
}

### think action

describe_think() {
	echo "Show a pensive cow"
}

describe_think_parameters() {
	echo "<text>"
}

describe_think_options() {
	echo "text : Text to display"
	echo "--sheep : Use a sheep rather than a cow"
}

do_think() {
	local params=
	while [[ ${1#--} != ${1} ]] ; do
		if [[ "--sheep" == ${1} ]] ; then
			shift
			params="${params} -f sheep"
		elif [[ "--" == "${1}" ]] ; then
			break
		else
			die -q "Unknown parameter ${1}"
		fi
	done

	echo "${@:-Am I a cow?}" | cowthink ${params}
}