docopt / docopt.go

A command-line arguments parser that will make you smile.
http://docopt.org/
MIT License
1.43k stars 108 forks source link

Documentation needs to better explain how to handle the returned arguments #31

Closed nwolff closed 6 years ago

nwolff commented 9 years ago

...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

neonsoftware commented 7 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.

aviddiviner commented 7 years ago

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.

neonsoftware commented 7 years ago

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.

neonsoftware commented 7 years ago

looking forward to your merge ➡️

mboersma commented 6 years ago

I think the improvements @aviddiviner made cover this well. Please open fresh new issues if there are still documentation gaps to address.