vorpal
vorpal copied to clipboard
Vorpal version 1 autocomplete problem
I created this video demonstrating the problem
https://www.useloom.com/share/40a9509bf03248d586d0357894f0edf4
I would like to use tab completion to access a directory
something like this:
node test/src/dev/node/foo.test.js
but using Vorpals autocomplete functionality does not make tab completing through a filesystem easy at all because Vorpal adds an extra character after the user hits tab. See the video.
My code to do the autocompletion looks like this:
vorpal.command('run [file]')
.description('run a single test script')
.autocomplete({
data: function (input: string, cb: Function) {
const basename = path.basename(input);
const dir = path.dirname(path.resolve(process.cwd() + `/${input}`));
fs.readdir(dir, function (err, items) {
if (err) {
return cb(null);
}
const matches = items.filter(function (item) {
return String(item).match(basename);
});
return cb(matches);
});
}
})
any word on this bird?
I think it might be this line https://github.com/dthree/vorpal/blob/8bb46ada64a3dac333b9f5b9e5ed72432aa26d0e/lib/autocomplete.js#L100
this one is important to me, if someone can help me with it - @dthree @milesj
Hi @ORESoftware. Thanks for the video. Yes, adding a space is intended functionality, and file system navigation is the one place I've observed this to come up as an issue.
Perhaps we can add a flag on the tabbed autocompletion command? In this way, you can make the space omission command-specific.
By the way, there's already a file-system autocompletion library:
https://github.com/vorpaljs/vorpal-autocomplete-fs
oh nice, let me try that fs autocompletion lib, if it doesn't work I will report back very soon