C
C#2y ago
BlakeFL

✅ System.CommandLine -> How to create a option without a parameter?

If I wanted to create an option that does not need anything passed into it how does that work with the latest version? I tried passing nothing to a nullable string option but that did not work. It seems like this might have worked with new Option() without type <t> before but that was removed in the newest version. Desired result: cmd input -> "tool servers -list" cmd response -> list of servers from api call or config file. servers is the subcommand and -list would be an option.
3 Replies
Thinker
Thinker2y ago
Are you talking about subcommands?
BlakeFL
BlakeFLOP2y ago
Well it is specifically about options. If I create an subcommand named servers and want an option of -list, how to I get that option to accept nothing as a parameter since I don't need one. Or should the the -list be another subcommand? I believe I figured it out. -list just needs to be a subcommand of servers and then I can add a handler for that. Works as expected. I think I was confused about commands vs options.
ZacharyPatten
ZacharyPatten2y ago
yeah you sound like you needed a command rather than an option I agree. but just throwing my opinion out here... I rather hate System.CommandLine. There are better alternatives
Want results from more Discord servers?
Add your server