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.

Need a way to inject current command (instead of root command)

See original GitHub issue

Is there an existing issue that is already proposing this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe it

I noticed that there is a decorator at present named InjectCommander, it can inject the root command object.

But sometimes, some functions requires to get the current command object, command.help() eg. different commands print different content.

Describe the solution you’d like

  • @InjectCurrentCommander() or
  • @InjectCommander({ current: true })

Teachability, documentation, adoption, migration strategy

No response

What is the motivation / use case for changing the behavior?

Get current command / sub-command object.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
jmcdo29commented, Jul 7, 2022

I think what I’m going to end up doing is adding a commandInstance property and making CommandRunner an abstract class (breaking change) instead of an intrerface then setting that value from the CommandRunnerService class when creating the command. That way, this.commandInstance now points to the current command. As the commands aren’t registered in the DI tree, it won’t be possible to do @InjectCommand() or anything like that, but this should be a decent solution instead

2reactions
jmcdo29commented, Jun 21, 2022

I’ll see if I can figure out some sort of way to implement this soon. Thanks for the suggestion

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is OS command injection, and how to prevent it?
In this section, we'll explain what OS command injection is, describe how vulnerabilities can be detected and exploited, spell out some useful commands...
Read more >
What Is Command Injection? | Examples, Methods & Prevention
Command injection is a cyber attack that involves executing arbitrary commands on a host operating system (OS). Learn more.
Read more >
A Pentester's Guide to Command Injection - Cobalt.io
Command injection is an attack in which the goal is to execute arbitrary commands on the host operating system via a vulnerable application....
Read more >
Run same command again but as root - sudo - Ask Ubuntu
The simplest way is to run: sudo !! This will run the last command but as super user.
Read more >
Command Injection
They have the same property that the query statement is not generated from user input and parameters are clearly identified. While SQL injection...
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