2
2
3
3
# run :: v0.0.1
4
4
5
+ function compact-file() {
6
+ sed -e ' /^$/d' -e ' s/^[[:space:]]//'
7
+ }
8
+
9
+ function optionally-compact-file() {
10
+ [[ " $* " == * ' --compact ' * ]] && compact-file || cat
11
+ }
12
+
5
13
function create-runfile() { local buffer=' '
6
14
if [[ " $* " != * ' --overwrite-runfile ' * ]] && [[ -e ' Runfile' ]]
7
15
then
@@ -10,7 +18,7 @@ function create-runfile() { local buffer=''
10
18
exit 1
11
19
fi
12
20
13
- buffer= " $( cat << EOF
21
+ optionally-compact-file " $@ " << EOF > Runfile
14
22
s start: stop # start app
15
23
run build env=dev # tasks can be run directly from other tasks
16
24
echo "starting app"
@@ -21,20 +29,13 @@ stop: # stop app
21
29
b build: lint # build app for environment [vars: env]
22
30
[[ -n \$ (env) ]] && echo "buiding app for \$ (env)" || echo "error: missing env"
23
31
24
- t test: build # run all tests or specific tests [vars: name1, name2, etc.]
32
+ t test: # run all tests or specific tests [vars: name1, name2, etc.]
33
+ run build env=test
25
34
[[ -n \$ (@) ]] && echo "running tests \$ (@)" || echo "running all tests"
26
35
27
36
l lint: # lint all files or specific file [vars: file]
28
37
[[ -n \$ (1) ]] && echo "linting file \$ (1)" || echo "linting all files"
29
38
EOF
30
- ) "
31
-
32
- if [[ " $* " == * ' --compact ' * ]]
33
- then
34
- echo " ${buffer} " | sed -e ' /^$/d' -e ' s/^\t//' > Runfile
35
- else
36
- echo " ${buffer} " > Runfile
37
- fi
38
39
}
39
40
40
41
function lowercase-file() {
@@ -67,7 +68,7 @@ function edit-file-smartcase() { local name=''
67
68
}
68
69
69
70
function print-file-smartcase() {
70
- cat " $( smartcase-file " $1 " ) "
71
+ cat " $( smartcase-file " $1 " ) " | optionally-compact-file " $@ "
71
72
}
72
73
73
74
function print-makefile() {
@@ -103,7 +104,7 @@ function main() ( set -euo pipefail
103
104
[[ " $* " == * ' --create-runfile ' * || " $* " == * ' --overwrite-runfile ' * ]] && \
104
105
create-runfile " $@ " && edit-file-smartcase runfile --confirm " $@ " && exit 0
105
106
[[ " $* " == * ' --print-runfile ' * ]] && \
106
- cd-to-nearest-file runfile && print-file-smartcase runfile && exit 0
107
+ cd-to-nearest-file runfile && print-file-smartcase runfile " $@ " && exit 0
107
108
[[ " $* " == * ' --edit-runfile ' * ]] && \
108
109
cd-to-nearest-file runfile && edit-file-smartcase runfile " $@ " && exit 0
109
110
[[ " $* " == * ' --edit-makefile ' * ]] && \
0 commit comments