-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbash-run-template
More file actions
30 lines (24 loc) · 810 Bytes
/
Copy pathbash-run-template
File metadata and controls
30 lines (24 loc) · 810 Bytes
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
#!/bin/bash
# - Functions that start with =_= are not shown by the ~help~ task.
# - Add a description by setting a variable with the function name replacing
# `-` with `_` an suffixing it with `_info`.
example_info="Example task"
function example {
echo "Task is not defined"
}
################################################################################
# Script help and run commands
function _help {
local tasks=$(grep --only-match '^\s*function\s\+[^_]\S\+' $0 | sed 's/^[ \t]*function[ \t]*//')
local lines=""
for task in ${tasks[*]}
do
local info=${task//-/_}_info
lines+="- $task\t${!info}\n"
done
echo "run <task> [<args>]"
echo "Available tasks:"
echo -e $lines | column -t -s$'\t'
}
TIMEFORMAT="Task completed in %3lR"
time ${@:-_help}