Skip to content
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

Parse docopt even if no args are passed #72

Open
kindermax opened this issue Mar 7, 2020 · 0 comments
Open

Parse docopt even if no args are passed #72

kindermax opened this issue Mar 7, 2020 · 0 comments

Comments

@kindermax
Copy link

kindermax commented Mar 7, 2020

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant