davetron5000 / gli

Make awesome command-line applications the easy way
http://davetron5000.github.io/gli
Apache License 2.0
1.26k stars 102 forks source link

autocomplete_commands false does not propagate to subcommands #287

Closed coreycarvalho closed 5 years ago

coreycarvalho commented 5 years ago

Given a command with subcommands (ex. command subcommand foobar), and autocomplete_commands(false), only the first subcommand does not autocomplete.

command sub would throw an error. command subcommand foo would autocomplete to command subcommand foobar.

I would expect command subcommand foo to also throw an error.

davetron5000 commented 5 years ago

Hmmm. I can't see anythning obvious. What happens when you run your app with GLI_DEBUG=true in the environment (e.g. GLI_DEBUG=true my_app subcommand foo)?

There's a couple places where we default to autocomplete true, but I can't see where the value from autocomplete_commands wouldn't fall through and set it to false.

atareshawty commented 5 years ago

👋I created a small example where autocomplete_commands false fails for a sub command. Here's the repo: https://github.com/Root-App/gli-auto-complete.

With that code, running: GLI_DEBUG=true ./bin/gli_auto_complete parent chil yields the following result:

09:22 $ GLI_DEBUG=true ./bin/gli_auto_complete parent chil
Using 'chil' as it's is short for child.
Set autocomplete false for any command you don't want matched like this
Running the child command

We're declaring the auto complete setting here. Maybe we have a misunderstanding of that setting. Is there anything else we need to configure to get the behavior we want?

If it helps, we're on GLI version 2.18.0

atareshawty commented 5 years ago

If this is indeed a bug, we'd be more than happy submit a PR

davetron5000 commented 5 years ago

The way you are using it looks correct (assuming that you cannot autocomplete parent command)

So yeah, this seems like a bug and if you are game to tackle it, I'm game to merge your PR! :)

atareshawty commented 5 years ago

https://github.com/davetron5000/gli/pull/288

atareshawty commented 5 years ago

I'm unable to close this issue, but I think it can be closed now

davetron5000 commented 5 years ago

oops, I got it.