-
-
Notifications
You must be signed in to change notification settings - Fork 754
Description
Description
I've found myself writing a lot of echo "<explanation of what next cmd does> commands with the silent: true property set, whenever I'm writing tasks for my users.
Let's pretend we want to supply a task that creates a file given via CLI_ARGS, without disclosing to our users what magic we used to do so (because of reasons). Currently, I would have to write something like this:
version: 3
tasks:
create-file:
cmds:
- cmd: echo "Creating requested file at {{ .CLI_ARGS }}..."
silent: true
- cmd: touch {{ .CLI_ARGS }}
silent: true
- cmd: echo "done!"
silent: trueoutput:
> task create-file -- foo.txt
Creating requested file at foo.txt...
done!This bloats the task, and makes it tedious to write and parse.
My request would be a new echo field, which would implicitly set silent: true on the command object, and print the echo field's value instead when it's run. Also, allowing it to be the only field set would do away
with all the { cmd: "echo <msg>", "silent": true} constructs:
version: 3
tasks:
create-file:
cmds:
- echo : Creating requested file at {{ .CLI_ARGS }}...
cmd: touch {{ .CLI_ARGS }}
- echo: done!The output should be identical:
> task create-file -- foo.txt
Creating requested file at foo.txt...
done!In summary:
Add a new field echo to the command object:
- When set to a non-empty string, its value is printed to stdout and the object's
silentproperty implicitly set totrue - When no
cmdordeferattribute is set, the command should behave identical to{ cmd: "echo <msg>", "silent": true}