dthree / vorpal

Node's framework for interactive CLIs
http://vorpal.js.org
MIT License
5.64k stars 280 forks source link

command autocompletion working for aliases too. #75

Closed fiatjaf closed 8 years ago

dthree commented 8 years ago

Awesome - thanks! Would you be able to throw in test coverage for this?

fiatjaf commented 8 years ago

There was no test for the previous autocomplete behavior, and I don't know how to test it.

dthree commented 8 years ago

Oh shoot - yeah I remember testing auto-completion was tricky. Okay, fine for now. Thanks!

fiatjaf commented 8 years ago

came up with this:

describe('command execution', function () {
  vorpal.ui.input('donal');
  vorpal.ui._activePrompt.screen.rl.cursor = 5;
  vorpal.ui.emit('vorpal_ui_keypress', {key: 'tab'});
  vorpal.ui.input().should.equal('donald trump ');
});

but session.getAutocomplete's trimmed variable comes up as undefined and so no match is found. Where is the error? What is the correct way to set this cursor?