Passing data for Default command
See original GitHub issueIs 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:
- Created 3 years ago
- Reactions:1
- Comments:5 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I just submitted #1091 to address this issue.
Replying to myself: I just realized that I can set the description of the default command by simply adding a
[Description]
attribute onMyCommand
class. 🤦♂️