Closed nwolff closed 6 years ago
I agree, an example that shows the parsing of arguments showcasing the various argument types would be very appreciated.
I think that, if it would exist, it would benefit the README page and showcase how nice the access actually is 👍
There are many cases to cover, but it doesn't mean one person has to do it all, @nwolff or @mboersma what do you think, might be collaborative and incremental ? I'd be in.
Take a look at my fork which handles this more cleanly: https://github.com/aviddiviner/docopt-go#api. I've added docs there which shows what to do with the returned opts that are parsed.
Hi @aviddiviner
first of all 👍 I like the handling in your fork.
And back to the topic, nice intro, end the bind examples and the parse args example. The list you do in there
flag, := opts.Bool("--flag") secs, := opts.Int("
")
is exactly what jumps to the eye of a possible new user, i guess, that's where the args are accessed and explicit simple accesses like these are powerful attraction. An even longer list with some other types of if checks would be fantastic.
Also the bind example, loved it.
looking forward to your merge ➡️
I think the improvements @aviddiviner made cover this well. Please open fresh new issues if there are still documentation gaps to address.
...especially since that part is the only thing golang specific.
By chance I found this example that helped:
https://github.com/docopt/docopt.go/blob/master/examples/type_assert/type_assert_example.go
But it is not super clear nor easy to find