taskrunner
taskrunner copied to clipboard
Pass cl args to tasks
Adds a withFlags
flag to taskrunner that allows an end user to provide a string of command line args that will be passed down to the task. Example usage looks like:
taskrunner --withFlags="--dryrun" taskname
It is left up to individual tasks to implement all arg behavior, and describe that behavior in the task.Description.
Notes:
- At the moment, this only works when taskrunner is used to invoke a single task. This is to prevent unintended side effects/argument collision among invoked tasks.
- This PR updates the type for task.Run, so existing tasks would need to be updated.
Pull Request Test Coverage Report for Build 194
- 3 of 15 (20.0%) changed or added relevant lines in 4 files are covered.
- No unchanged relevant lines lost coverage.
- Overall coverage decreased (-0.1%) to 35.231%
Changes Missing Coverage | Covered Lines | Changed/Added Lines | % |
---|---|---|---|
goextensions/builder.go | 0 | 2 | 0.0% |
cache/cache.go | 0 | 3 | 0.0% |
runner.go | 0 | 7 | 0.0% |
<!-- | Total: | 3 | 15 |
Totals | |
---|---|
Change from base Build 185: | -0.1% |
Covered Lines: | 359 |
Relevant Lines: | 1019 |
💛 - Coveralls
Looks good! This is going to require updating every task definition when it's merged with backend right? And also updating whatever is autogenerating tasks?
@Shaun1 yes - i'll do that when i re-govendor taskrunner into our repo.
Question: how different is it passing flags like this vs using environment variables
ex:
GRPC_PORT:1234 taskrunner safetyserver
What are the advantages of flags vs env variables?
Question: how different is it passing flags like this vs using environment variables ex:
GRPC_PORT:1234 taskrunner safetyserver
What are the advantages of flags vs env variables?
I think that for a lot of tasks that are more tool-like or have a more defined "do this process then exit" flow (eg: import a fresh database), using environment variables feels strange. Flags feel like a better fit because they're designed to be like "for this specific run of this program, use this input".
If taskrunner allows for CLI args, tasks can follow a more "normal" dev tool flow, and they might be easier to port in a future scenario where we don't use taskrunner anymore. At the moment, all tasks must be architected around this limitation of taskrunner instead of written in a more usual way.
Closing this PR since it is addressed by https://github.com/samsarahq/taskrunner/pull/48