taskrunner icon indicating copy to clipboard operation
taskrunner copied to clipboard

Pass cl args to tasks

Open EmmaOnThursday opened this issue 5 years ago • 5 comments

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.

EmmaOnThursday avatar Dec 13 '19 11:12 EmmaOnThursday

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 Coverage Status
Change from base Build 185: -0.1%
Covered Lines: 359
Relevant Lines: 1019

💛 - Coveralls

coveralls avatar Dec 13 '19 11:12 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 avatar Dec 13 '19 15:12 Shaun1

@Shaun1 yes - i'll do that when i re-govendor taskrunner into our repo.

EmmaOnThursday avatar Dec 13 '19 15:12 EmmaOnThursday

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?

stansey avatar Dec 13 '19 16:12 stansey

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.

EmmaOnThursday avatar Dec 16 '19 14:12 EmmaOnThursday

Closing this PR since it is addressed by https://github.com/samsarahq/taskrunner/pull/48

toniihsia avatar Jun 08 '23 16:06 toniihsia