-
Notifications
You must be signed in to change notification settings - Fork 48
Description
Hello. I am writing an utility and i decided to use your library. Right now i have 4 issues and maybe something can be improved, if you'd like:
-
The idea of commands is very nice. However, right now i can't have multiple commands and run one command by default (when no args specified). Yes, this might be cryptic for users, but it's normal behavior for GUI apps (like
Process Explorerand other Sysinternals tools): it runs normally by default, but if you pass args, it displays help in MessageBox or does what args tell it to do.
Right now i'm using this hack:- if there are no args
- or if there are args, and if first arg is not a command (checking by using copy of
private static GetMatchingCommandbecause it'sprivate!) - and arg[0] is not
help - then insert name of default command to args[0]
- then let your library do all the job like normal
So i think you can add an optional argument to
DispatchCommandor add metadata field to command to allow some command run as default one. -
As i mentioned, i'm writing a GUI app. I don't need
intreturn code, and mymainhasvoidreturn type. If everything was ok, app does nothing, otherwise it displays aMessageBoxwith message and icon. However, can't return more thanintfrom a command. Right now i just havepublic static MyResult Result {get; set;}field inProgramclass and set it from commands which is obviously too ugly. Maybe you can introduce genericConsoleCommand<T>to allow users to return any type? -
I have strange behavior with setting default value for optional argument. If i don't specify the value, it is
nullevery time. Maybe that's intended, but i expected from docs that Action gets called and i can check fornulland set default value from there. For example:HasOption("c|config:", "Config file", x => ConfigFileName = x ?? "test");ConfigFileNameis not set from this Action, i need to back it up with default value elsewhere. -
I can't get
:or=in prototype to show default value instead ofVALUE. Like in example above, i have in generated help:-c, --config[=VALUE] Config file. Am i missing something? I'd like it to be-c, --config[=test] Config filebut when i specify"c|config:test", i gen an exception.