1 # Oil Configuration
2 #
3 # The "COWS" pattern
4
5
6 #### use bin
7 use
8 echo status=$?
9 use z
10 echo status=$?
11
12 use bin
13 echo bin status=$?
14 use bin sed grep
15 echo bin status=$?
16
17 ## STDOUT:
18 status=2
19 status=2
20 bin status=0
21 bin status=0
22 ## END
23
24 #### use dialect
25 shopt --set parse_brace
26
27 use dialect
28 echo status=$?
29
30 use dialect ninja
31 echo status=$?
32
33 shvar _DIALECT=oops {
34 use dialect ninja
35 echo status=$?
36 }
37
38 shvar _DIALECT=ninja {
39 use dialect ninja
40 echo status=$?
41 }
42
43 ## STDOUT:
44 status=2
45 status=1
46 status=1
47 status=0
48 ## END
49
50
51 #### CI config example
52 shopt --set oil:basic
53
54 # this could be ci.coil too
55 var config_path = "$REPO_ROOT/spec/testdata/config/ci.oil"
56
57 proc task(name, &block) {
58 echo "task name=$name"
59
60 # Note: we DON'T use evalblock here!
61 #
62 # Instead we really want blockstring? or blockstr() ?
63 # blockcodestr() ? We validate the literal code and put it in JSON
64
65 # Note that we accept Oil in addition to shell, but we should probably
66 # accept shell.
67 #
68 # You could have 'sh-task' and 'oil-task' ?
69 }
70
71 task foo {
72 echo 'running task foo'
73 }
74
75 shopt --set parse_equals {
76 shvar _DIALECT=sourcehut { # use dialect should FAIL if this isn't set
77
78 const first_words = %( +proc/task +builtin/{echo,write,printf} )
79 # Other syntaxes:
80 # - no sigil: proc/task
81 # - % which are like symbols, would be confusing
82 # - other namespaces:
83 # - +alias/myalias
84 # - +option/errexit
85 # - coprocess, container?
86 # - shobj_get('+option/errexit') ? Make it first class?
87
88 # TODO: This should be bin/oven --source foo_dialect.oil -- foo.oil
89 # Do we also need --source-after? or -c after?
90
91 const config = _vm_eval(config_path, first_words)
92 }
93 }
94
95 json write :config
96
97 ## STDOUT:
98 {"image": "debian/buster"}
99 ## END
100