aboutsummaryrefslogtreecommitdiff
path: root/core/help
blob: 98abd1e35defa74b2820b4e4ce3ccabe9059fc25 (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
#!/bin/sh
[ "$1" = "info" ] && echo "show this very message" && exit 2

cat << EOF
$progname -- daemonless posix pomodoro timer

usage:
	$progname [options] [action] [action options]

options:
	-h, --help  show help

actions:
EOF

IFS=':'
find $path -type l,f -perm /u=x,g=x,o=x 2>/dev/null | while read -r action ; do
	action_name="$(basename "$action")"
	if [ -L "$action" ] ; then
		printf '%s\t%s\n' "$action_name" "same as $(basename "$(readlink -f "$action")")"
	else
		action_info="$("$action" info)"
		[ $? -eq 2 ] && printf '%s\t%s\n' "$action_name" "$action_info"
	fi
done | awk '
	BEGIN { FS = "\t" }
	{
		if (printed[$1]) next
		printf("\t%-13s  %s\n", $1, $2)
		printed[$1] = 1
	}
'

cat << EOF

if no action is provided, the \`state\` action is chosen by default
EOF