55 |
56 |
Module fourmi.builtins
57 |
Common helpers and basic tasks
58 |
59 |
Info:
60 |
61 | - Copyright: Benoit Giannangeli 2019
62 | - License: MIT
63 | - Author: Benoit Giannangeli
64 |
65 |
66 |
67 |
68 |
69 |
70 | sh (program, ...) |
71 | Runs a command captures stderr and returns it as error message |
72 |
73 |
74 | outdated (original, target) |
75 | Returns true if a file is outdated |
76 |
77 |
78 | __ (str[, context]) |
79 | String interpolation helper
80 | - `${VARIABLE}` -> `os.getenv "VARIABLE"`
81 | - `#{variable}` -> `variable` in `context` or caller locals or `_G`
82 | - `~` -> `os.getenv "HOME"`
83 | - `???` -> `_G.__fourmi_vars[variable]` |
84 |
85 |
86 | var (key, value) |
87 | Set a fourmi variable |
88 |
89 |
90 | builtins.task.sh (command, ...) |
91 | Create a task that runs a single shell command |
92 |
93 |
94 |
95 |
96 |
97 | task |
98 | Builtin tasks |
99 |
100 |
101 |
102 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 | -
125 |
126 | sh (program, ...)
127 |
128 | -
129 | Runs a command captures stderr and returns it as error message
130 |
131 |
132 |
Parameters:
133 |
134 | - program
135 | string
136 | command to run
137 |
138 | - ...
139 | string
140 | program arguments If an arguments contains spaces it'll be quoted
141 |
142 |
143 |
144 | Returns:
145 |
146 |
147 | boolean
148 | true if command succeded
149 |
150 | Or
151 |
152 |
153 | string
154 | message in case of failure
155 |
156 |
157 |
158 |
159 |
160 |
161 | -
162 |
163 | outdated (original, target)
164 |
165 | -
166 | Returns true if a file is outdated
167 |
168 |
169 |
Parameters:
170 |
171 | - original
172 | string
173 | If alone checks that it exists
174 |
175 | - target
176 | string
177 | Outdated if not present or older than original
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 | -
187 |
188 | __ (str[, context])
189 |
190 | -
191 | String interpolation helper
192 | - `${VARIABLE}` -> `os.getenv "VARIABLE"`
193 | - `#{variable}` -> `variable` in `context` or caller locals or `_G`
194 | - `~` -> `os.getenv "HOME"`
195 | - `???` -> `_G.__fourmi_vars[variable]`
196 |
197 |
198 |
Parameters:
199 |
200 | - str
201 | string
202 | String to interpolate
203 |
204 | - context
205 | table
206 | Table in which to search variables to interpolates
207 | (optional)
208 |
209 |
210 |
211 | Returns:
212 |
213 |
214 | string
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 | -
223 |
224 | var (key, value)
225 |
226 | -
227 | Set a fourmi variable
228 |
229 |
230 |
Parameters:
231 |
232 | - key
233 | string or table
234 | or table of (key, value)
235 |
236 | - value
237 | string, number or boolean
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 | -
248 |
249 | builtins.task.sh (command, ...)
250 |
251 | -
252 | Create a task that runs a single shell command
253 |
254 |
255 |
Parameters:
256 |
257 | - command
258 | string
259 |
260 |
261 | - ...
262 | string
263 |
264 |
265 |
266 |
267 | Returns:
268 |
269 |
270 | task
271 |
272 |
273 |
274 |
275 |
276 |
277 |
278 |
279 |
280 |
281 |
282 | -
283 |
284 | task
285 |
286 | -
287 | Builtin tasks
288 |
289 |
290 |
291 |
292 |
293 |
294 |
295 |
296 |
297 |
298 |
299 |
300 | -
301 |
302 | builtins.task.ls
303 |
304 | -
305 | A task that list files
306 |
307 |
308 |
309 |
310 |
311 |
312 |
313 |
314 | -
315 |
316 | builtins.task.empty
317 |
318 | -
319 | Empty files of a directory
320 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
328 | -
329 |
330 | builtins.task.outdated
331 |
332 | -
333 | Filter out up-to-date files
334 |
335 |
336 |
337 |
338 |
339 |
340 |
341 |
342 |
343 |
344 |
345 |