-
-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A couple of enhancements... #7
Comments
|
So, the easy response first... #2 is my bad. I'm generating it. I have a layer on top of As for #1,
will produce the following in the
This snippet:
will produce the following in the
It's a way to programmatically annotate/decorate the Thanks for your consideration... |
I am not sure if I understand 2) in full. Is there still some feature request open?
|
I'm not going to quibble about what you call it ;-) I only picked separator because that's what it's called in Ruby optionparser... Actually, I'd prefer to call it what it is -- annotation. Just as an aside, do you know of a package does something like the Ruby gem thor (also here)? This may be tough to accomplish given the fact that Go doesn't have the object orientation or the dynamic typing that Ruby does. I looked at urfave/cli and it seems to be the most complete but, OMG!, the setup is horrendous...even for something simple. Maybe I'm missing something... I'm just getting started with Go after years of programming almost exclusively with Ruby. Ruby has a lot of advantages but it's slow and most gems are not well-maintained. Plus, in order to build the most-performant JIT, you need to install Rust (!!!). Every release lately seems to break something... Your |
Implement
OptionParser.Separator()
to be able to insert stuff in the--help
output programmatically (e.g., newlines). See the Ruby doc.I have a program (called
opt
) that validates a shell script command line against specification provided in a JSON file. Here's a snippet:This specification defines
-x, --xyzzy
as a range. The value of-r, --range
must be an integer in the range (0..5) with a default of 3.I use
ParseFrom()
to supply the shell script command line to my Go program (via theOptionParser.Extra
data). I have a command line flag on my Go program that sets the script name:Hopefully, you get the idea...
Lets say that I supply an non-existent argument as part of the
Extra()
; e.g.The map sent to
ParseFrom()
is[scriptHame --the script --args --nonexistent]
. I have a couple of lines of code to ensure that the first item in the map isscriptName
.ParseFrom()
generates the appropriate error (as it should):I would like this message to be:
So, in a nutshell, if you parse args with
ParseFrom(foo)
, any error messages thatParseFrom()
generates should usefoo[0]
as the program name.I hope this is clear. Please reply if you have questions.
Thanks in advance...
P.S. It's a simple matter to make
foo[0]
the program name:If
op.Extra
has[--the script --args --nonexistent]
,foo
will have[scriptHame --the script --args --nonexistent]
.The text was updated successfully, but these errors were encountered: