Commander.js: Tab completion?

Created on 29 Mar 2015  Â·  14Comments  Â·  Source: tj/commander.js

Has anyone implemented tab completion with commander? Complete looks like a working module, but it seems like this would be perfect territory for commander.

Another module: completion

Most helpful comment

For anyone following this issue, I strongly recommend you check out oclif.

It's extremely well-designed, and the autocompletion is fantastic.

All 14 comments

It would be great to have shell auto-completion for already generated program help without write much code. Suggestions? I can't find anything suitable at npm.

Interesting. PR about this feature is welcome~

E.g.:

  • if input starts with - then autocomplete global options and command options (if command is already typed)
  • if you don't yet choose a command - suggest commands
  • allow to extend/override autocompletion behaviour programmatically (to suggest custom parameters for options (as branches in git), etc)

This would be a great feature. =D

I looked into this in the past and had a working prototype (not using a third party module). However, getting it working for windows is a whole other ballgame. I'd like to see a powershell solution so commander can continue to be multi-platform

I have found commander-auto-complete, but which is not good enough to use for product.

Windows support has been one of the reasons in the past that I never pursued this personally. That, and the fact that I think a solid usage doc with a levenshtein distance check on attempted command executions (like git) usually covers the case. IMHO, I feel like if you're leaning on autocomplete for your CLI, you might have a design issue with it. Not to say that they're aren't real cases that could use it, but I'm of the opinion they should be rare.

Just an update on this – those looking for CLI auto-completion might want to consider switching to Vorpal. Vorpal is a bit more involved, but it has a lot of the more advanced features built-in.

@bitjson Vorpals autocompletion is quite awesome, yet the lack of typescript typings is a dealbreaker for me. Yet commander has them.

I wished commander would also support autocompletion :)

@tonylukasavage don't dismiss autocompletion as being a quick fix for poor design decisions. It can also be user for values for example:

addpermission user@... system.admin system....

Many database CLIs implement this kind of autocomplete for table names and fields.

@bitjson Vorpal works great as a shell, however due to some bugs, it's pretty much impossible to invoke a single command from command line and quit

An alternative is also Yargs: https://github.com/yargs/yargs

For anyone following this issue, I strongly recommend you check out oclif.

It's extremely well-designed, and the autocompletion is fantastic.

@bencao has done an integration with Omelette in #907, but it was decided not to include it in Commander itself at this time.

Not currently planning to build tab completion into Commander itself, so closing this issue.

I am interested in this as a problem, so please let us know about packages which integrate well with Commander.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

RoXioTD picture RoXioTD  Â·  4Comments

shadowspawn picture shadowspawn  Â·  3Comments

aminch picture aminch  Â·  3Comments

mwittig picture mwittig  Â·  4Comments

san-templates picture san-templates  Â·  5Comments