It would be useful if a command completion callback had information about the parameters given so far.

For example, for the module builder 'mb' command"

$ drush mb modulename hookname hookname hookname

I can autocomplete hook names. But if I knew which position the user was at, I could also offer to autocomplete the names of existing modules.

Comments

moshe weitzman’s picture

Assigned: Unassigned » owen barton
owen barton’s picture

The challange here is that the complete callback results are cached, so we can rapidly complete subsequent responses from the cache without needing to bootstrap Drupal (which is slow, relative to the normal completion response time). In other words, for caching to work, we need to be able to capture all posisble completions for a command.

I can see your point about argument order though - it seems like we could easily provide a mechanism for providing argument-position specific completion results for commands that take arguments with different meaning/content. The last argument would presumably repeat for all subsequent arguments.

This wouldn't allow subsequent arguments to depend upon prior arguments for context however (because of the caching) - for that we would need to return some kind of tree like a nested array, perhaps with some way to reference other parts of the tree (to prevent duplication). I'll have a think - there may be some simple way to extend the existing structure to allow this.

greg.1.anderson’s picture

Status: Active » Closed (won't fix)
Issue tags: +Needs migration

This issue was marked closed (won't fix) because Drush has moved to Github.

If this feature is still desired, you may copy it to our Github project. For best results, create a Pull Request that has been updated for the master branch. Post a link here to the PR, and please also change the status of this issue to closed (duplicate).

Please ask support questions on Drupal Answers.

joachim’s picture

Status: Closed (won't fix) » Closed (duplicate)