dthree / vorpal

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

Error first callbacks not available with autocomplete? #254

Closed ORESoftware closed 6 years ago

ORESoftware commented 7 years ago

Maybe the example is wrong (a doc bug), but in the tab completion section I see:

vorpal.command('feed [animal]')
  .autocomplete({
    data: function (input, callback) {
      getAnimals(function (array) {
        callback(array);            // << not an error-first callback?
      });
    }
  })
  .action(feedThem);

this seems incorrect - if we returned Promise.reject('some error'), then vorpal should handle that somehow.

Likewise, if we have an error, we should be able to pass the error as the first argument to the callback. Is this a doc bug, or something more concerning?

oboecat commented 6 years ago

Is there any update on this?

ORESoftware commented 6 years ago

yeah I think vorpal version 1.x just doesn't have error first callbacks in some places, hopefully with version 2 they fix that pattern. You have to use cb(matches); instead of cb(null, matches);.