docopt.go
docopt.go copied to clipboard
Parse docopt even if no args are passed
Hi. I am looking for a future to parse docopt even if no args were given for parser.
Real use-case - I want to get all flags (by flag I mean all options a command can receive) and use them in autocomplete.
Basically I need only keys from opts map[string]interface{}
map of flags. I then filter them as I need.
Example:
doc = `Usage: somecli run [--debug] [--config=<config>] <app>
Options:
--debug Run app with debug
--config=<config> Run with a config file
<app> An app to run
`
onlyFlage := true
opts, err := docopt.ParseDoc(doc, onlyFlags)
The values of flags doesn't matter in this case and can be default values (bool, empty string, nil, etc)
I am ready to implement this feature if you are okay with an idea. Thanks!