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.

Tasks: allow passing arguments to tasks

See original GitHub issue

Example:

const hello = project.addTask('hello');
project.exec(`echo Hello, $@!`);
$ pj hello "world"
Hello, world!

Questions

  1. The $@ notation is just an example. Perhaps it would be easiest to support this by injecting the arguments into environment variable(s).
  2. Would be amazing if tasks could leverage yargs’ engine to parse switches.
  3. Should tasks also “register” positional arguments and switches for yargs?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:13
  • Comments:21 (16 by maintainers)

github_iconTop GitHub Comments

6reactions
pgolluccicommented, Dec 13, 2020

Another use case yarn deploy --profile damadden88

4reactions
Chriscbrcommented, Feb 6, 2021

Maybe as an escape hatch for all tasks, we could allow extra arguments to be passed automatically after a “–”, as in:

const deploy = project.addTask('deploy');
deploy.exec(`cdk deploy`);
$ pj deploy -- --all
... runs 'cdk deploy --all'

And meanwhile, more fancy argument-insertion could be allowed like so:

const lint = project.addTask('lint');
lint.exec(`eslint --ext .ts,.tsx $@ src tests`);
$ pj lint --fix -- build-tools
... runs 'eslint --ext .ts,.tsx --fix src tests build-tools'
Read more comments on GitHub >

github_iconTop Results From Across the Web

Task.Run with Parameter(s)? - Stack Overflow
This is the best answer as it allows a state to be passed in, and prevents the possible situation mentioned in Kaden Burgart's...
Read more >
TASK ARGUMENTS PASSING - Verification Academy
inside write0 and read0 and marchrun i am unable to get variables(addr,data) which are passing like arguments to the tasks
Read more >
Task parametrization, getting arguments from command line
It is possible to pass option parameters to the task action through the command line. Just add a params field to the task...
Read more >
Authoring Tasks - Gradle User Manual
Task outcomes; Defining tasks; Locating tasks; Configuring tasks; Passing arguments to a task constructor; Adding dependencies to a task; Ordering tasks ...
Read more >
Correct way to provide parameter to C# Task - Dot Net For All
In this article I will discuss the correct way to provide input parameter to the task and not to use the shared variable...
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