Closed smarie closed 5 years ago
Note that we could use this opportunity to allow users to insert comments in their command lines, too. These would be removed automatically before being sent to shell.
def task_elegant():
return {
'actions': ["""
echo 'hello' # says hello
echo 'world' # says world
"""],
'verbosity': 2,
}
It would also be interesting to support this syntax everywhere a string represents a command (for example in 'uptodate'
)
Why don't you call a shell script? Most editors will give a much better authoring experience that way... if the logic is complex and requires comments, I'd use a python action and uptodate implementation in the first place, so I can test and debug...
I agree with Mike.
Thanks @moltob ! Unfortunately calling a shell script breaks windows/mac/linux portability. In many of my libraries where the build system is travis or appveyor I end up calling bash or bat scripts, or python scripts, so I very much know what are the other ways to do this "less elegantly" :) .
But consider the case where people just want to call
conda activate xxx
python -c "command1"
python -c "command2"
conda deactivate # I guess this is optional since subprocess dies anyway
These three simple commands are common to all systems we target (we assume that conda is used on all targets for this project for portability purposes). Would it really be elegant to create a dedicated script just for this, as you suggest ? Certainly not. And using a python callable for this would not as well, as the user would need to reimplement all the code you have already done in CmdAction
: a bit of a waste of time...
Hi,
First of all many thanks for this project - it was a relief for me to find that someone had the same needs than us to escape from the legacy make-like build tools while preserving the good features. From what I've seen up to now, you did it quite well!
I have been struggling to find information about the possibility to run several commands in the same process in a task.
As of today it is possible to do it using a shell-dependent separator:
It feels like it could be so much more elegant :) for example I would suggest:
Would that make sense ? If so I can try to work on a PR.
Note for the record, that my initial need was not to call 'echo' but to activate a conda environment before running other commands :)
See also https://stackoverflow.com/questions/39721924/how-to-run-multiple-commands-synchronously-from-one-subprocess-popen-command