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

Auto-complete some words #2

Open
Hywan opened this issue Mar 11, 2014 · 6 comments
Open

Auto-complete some words #2

Hywan opened this issue Mar 11, 2014 · 6 comments

Comments

@Hywan
Copy link
Contributor

Hywan commented Mar 11, 2014

Hello :-),

I think it would be great to use Hoa\Console\Readline\Autocompleter\Word to autocomplete some words, like $asserter, integer, float and all the asserters.

Thoughts?

@jubianchi
Copy link
Owner

+1 : I'm trying to find some good rules to let autocompleters handle eveything.

For example :

  • if the line begins with $asserter we complete with atoums assertions
  • if the line begins witha ! we complete with native shell commands
  • if the line begins with a : we complete with atoum-shell commands
  • ...

@Hywan
Copy link
Contributor Author

Hywan commented Mar 11, 2014

Do you want one autocompleter or aggregated ones?

@jubianchi
Copy link
Owner

the shell works a bit differently at the moment: it uses a "late-binding" strategy : autocompleters are not bound when the shell boots.

The only completer I bind is the following : https://github.com/jubianchi/atoum-shell/blob/master/classes/input/completer.php

This one acts as a dispatcher, delegating the completion to the appropriate command. So I don't think I need an aggregate for now. At least, I don't need it until I refactor the way it's handled.

For now, I thnik each command will provide his own completer depending on what it has to complete:

  • for $asserter-, :- and !-prefixed commands, I'll use a word completer
  • the other will likely be handled by a path completer

@jubianchi
Copy link
Owner

A command could also provide more than one completer, depending on what the user typed. For example, the :foo command could take a path as its first argument and the something that is word-completed so it will dynamically change its own strategy, providing a different completer depending on the user current input.

@Hywan
Copy link
Contributor Author

Hywan commented Mar 11, 2014

The Hoa\Console\Readline\Autocompleter\Aggregate acts like your custom completer. It works with a collection of autocompleters and tries to find the one that is able to autocomplete the current prefix. I wonder if it is possible to create an aggregation of aggregated autocompleters. Possibily yes. The highest aggregation would have .* as the word definition. Then, another aggregation will have: ^\$asserter->.*, with Word and other autocompleters etc.

But I think that a simpler solution would be to solve hoaproject/Console#10. Thoughts? Would it fit your needs? Based on a pattern, we autocomplete “places” (this is how I see it), similarly to Zsh.

@jubianchi
Copy link
Owner

@Hywan I have to give a try on using the new aggregated autocompleter to see if it fits. If yes, I'll use it ;)

I'll keep you updated ;)

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

2 participants