question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

command line arguments for task creators

See original GitHub issue

doit already support Task parameters, but they are not convenient to be used with task-groups.

Example of proposed feature:

from doit import task_param

@task_param({'name':'param1', 'short':'p', 'default':'default value'})
def task_py_params(param1):
    for name in ['foo', 'bar']:
        yield {
            'name': name,
            'actions':['echo {}'.format(param1)],
        }

doit would be responsible for injecting parameter values when executing task-creator functions.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:4
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
rbdixoncommented, Jul 29, 2019

Well, strictly, none of them… though they are all interesting (and valid) usage considerations. My only intent was to provide a way for a task creating function to access command line arguments. In my own doit-based automations I’ve done weird things to compensate for not having this particular behavior. Other examples where people have gotten stumped without this feature:

I used a decorator because a) that’s what @schettino72 proposed, and b) it makes sense because if one wishes to preserve the doit-style of using a normal Python function arguments to deliver command line arguments to the task generator the definition for those command line arguments must be available before the task generating function has executed. Something other than a decorator could be used, of course, but a decorator at least puts the definition right next to the the function that will benefit from it. There could be other ways, though!

What you implemented in PR #321, IMHO, could be useful. I’ll leave a comment on that PR.

0reactions
smariecommented, Jul 29, 2019

There seem to be several features behind this ticket:

  • first, the fact that a “group task” exists as a task in doit, even if the user is not aware of it today. We could offer the user with the capability to edit that group task. This is the direction proposed by PR #321, and it could go much further (adding actions executed at the end of the group for example).

  • second, the fact that subtasks in a group do not today have the possibility to inherit from common group behaviour, in particular parameter definition. This is also the direction proposed by PR #321: when the user defines a parameter on the group task, it is copied on all subtasks.

  • finally, the fact that parameters could be defined in a more intuitive way using a decorator. I insist that this does not seem specific to subtasks at all, except if I misunderstood something (@schettino72 can you confirm ?). If we go down that road of providing decorators, users will of course ask for more and ask that every aspect of tasks could be determined with decorators… Just like in letsdoit. That is why at first I was not fond of using a decorator here: just for API consistency reason. Since current API heavily relies on generator api, it was more consistent to continue to use it.

@rbdixon which part of the above topics does your PR tackle ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Task parametrization, getting arguments from command line
Parametrizing tasks with command line arguments and environment variables. ... Command line arguments may also be passed to task creators.
Read more >
How to pass an argument to a Windows Scheduled Task with ...
I've worked with scheduled tasks and you generally put the arguments in its own text input box. ... Then from the command line...
Read more >
Get Process List with Command Line Arguments
The arguments for a process can tell you where configs are, what passwords might have been used or just tell you the correct...
Read more >
schtasks create - Microsoft Learn
Reference article for the schtasks create command to automate tasks.
Read more >
How to view command line arguments for a running app on ...
This is the easiest method for viewing command-line arguments for a running app on Windows 10. Open Task Manager. Right-click the header of ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found