blob: 60d42709ee417438150c926b2964daa22de3c123 (
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
|
#!/bin/bash -euE
. libremessages
stem=pbs
list_commands() {
find ${PATH//:/ } -type f -executable -name "$stem-*" \
-printf '%f\n' 2>/dev/null | sed "s/^${stem}-//;/--/d"
}
master_usage() {
echo "Usage: ${pbs_short:-${stem}} COMMAND [OPTIONS]"
echo
echo "Commands:"
list_commands | sed 's/^/ /'
}
help_usage() {
echo "Usage: ${pbs_short:-${stem}} help [OPTIONS] COMMAND"
echo "Shows the manual page for a command"
echo ''
echo 'Options:'
echo ' -h Show this message'
}
main() {
if [[ $# < 1 ]]; then
master_usage
else
if in_array '-h' "$@"; then
help_usage
else
man "$stem-$1"
fi
fi
}
main "$@"
|