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

Add autocomplete toggle #211

Merged
merged 11 commits into from
Mar 3, 2015

Conversation

chrisarcand
Copy link
Contributor

Adds an option to the DSL for enabling/disabling the simple autocomplete feature in CommandFinder:

autocomplete_commands false

Full doc:

If you're curious, the desire to have this feature comes from sportngin/octopolo#34
We have a deployable command in one of our CLI gems and deploy in another - and people (more than once) have accidentally marked their feature branches for merging when they intended a deployment :)

Other small tidbits:

  • Revamped CommandFinder and GLIOptionParser to use options hashes in their method signatures. This allows for much greater flexibility in doing something such as this autocomplete feature without constantly just pushing more and more parameters into the method signatures.
  • Full tests for CommandFinder written before I refactored the class a bit. Things are reordered and pushed around but the functionality (beyond the toggle) should be the same.
  • Lastly, I also added (in the spirit of Git-Like-Interface) the same warning you'd see in Git if a command is autocompleted. However, I'm unsure how you interface with the CLI output so the warning does get printed in tests. Any idea/opinion on how I should handle that?

The tests all pass, but do let me know if you see anything fishy that I missed. Thanks Dave!

Methods and options are cleaner. The options allow flexibility for
adding features, such as the one I'm adding in this pull request
(enable/disable autocorrect on partial commands)
Delegate some work to a helper method; also I think
commands_with_aliases is a bit more helpful to read, the intent wasn't
really coming to me quickly when I first read it.
This allows for easier passing of things without constantly changing the
method signature
@chrisarcand chrisarcand changed the title Add autocorrect toggle Add autocomplete toggle Feb 27, 2015
@davetron5000
Copy link
Owner

Ah, yeah good idea on this feature. Briefly skimming, this looks good, but I'll give it a more thorough look this weekend.

@davetron5000 davetron5000 merged commit 4425b19 into davetron5000:gli-2 Mar 3, 2015
@davetron5000
Copy link
Owner

Thanks for this. I wrapped the warning puts in an if ENV["GLI_DEBUG"] block, since the shortened forms aren't a user mistake.

@chrisarcand
Copy link
Contributor Author

Sweet 👍 Thanks Dave!

@davetron5000
Copy link
Owner

This is up as 2.13.0 and the online RDoc should be updated. Thanks again!

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

Successfully merging this pull request may close these issues.

None yet

2 participants