How to get an argument when a command comes after an argument? #504
Unanswered
dan-sherwin
asked this question in
Q&A
Replies: 1 comment
-
You need to create distinct named types for the different levels of your CLI, rather than inlining type definitions, then you can inject them into the Run() method as arguments. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I want to be able to pass an argument into the app and then follow that argument with a command. Something like:
./app deviceName powerOn
I have a struct that looks like this:
Currently the only way I have been able to figure out how to get the deviceName into the PowerOnCommand.Run function is to do the following:
Then I can access deviceNameStr as a global variable but doing it this way seems kind of hackish to me and I cant help but think that I am missing a more simplistic way to retrieve that argument from within the command run function? Any help would be appreciated.
}Dan
Beta Was this translation helpful? Give feedback.
All reactions