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.

Passing data for Default command

See original GitHub issue

Is your feature request related to a problem? Please describe. It looks like you can’t set Data property for “default” command.

Describe the solution you’d like Either use Data defined in config for same type of command or ability to specify context for the “default” command, same as regular command.

Additional context

Example code:

var externalDataObject = new { AdditionalContext = "myContext" };

var app = new CommandApp();
app.SetDefaultCommand<MyCommand>();
app.Configure(config =>
{
    config
        .AddCommand<MyCommand>("myCommand")
        .WithData(externalDataObject);

    config
        .AddCommand<MyAnotherCommand>("myAnotherCommand");
});

If you call the app like myApp myCommand --myArg xxx then the MyCommand will be called and “context” will have externalDataObject value, but if you call it like myapp --myArg xxx then the MyCommand will be called but “context” will not have externalDataObject value.

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
0xcedcommented, Nov 25, 2022

I just submitted #1091 to address this issue.

0reactions
0xcedcommented, Feb 15, 2023

My current workaround is to set it through reflection.

Replying to myself: I just realized that I can set the description of the default command by simply adding a [Description] attribute on MyCommand class. 🤦‍♂️

Read more comments on GitHub >

github_iconTop Results From Across the Web

Assigning default values to shell variables with a single ...
For command line arguments: VARIABLE="${1:-$DEFAULTVALUE}". which assigns to VARIABLE the value of the 1st argument passed to the script or ...
Read more >
Default arguments in Python
Default values indicate that the function argument will take that value if no argument value is passed during the function call.
Read more >
How to pass data between shells without reading/writing to ...
I'm trying to pass commands from a second terminal running locally, and without editing the first process. If I'm able to pass data...
Read more >
Bash run a program and repeatedly pass it data
I need to write a bash script to run a program and then every 5 seconds pass data to this program. The program...
Read more >
Pass data between destinations
Define destination arguments. To pass data between destinations, first define the argument by adding it to the destination that receives it by following...
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