index.js 573 B

1234567891011121314151617181920212223242526
  1. 'use strict';
  2. const abbrev = require('abbrev');
  3. const store = {
  4. page: require('./page'),
  5. post: require('./post'),
  6. route: require('./route'),
  7. tag: require('./tag'),
  8. category: require('./category')
  9. };
  10. const alias = abbrev(Object.keys(store));
  11. function listConsole(args) {
  12. const type = args._.shift();
  13. // Display help message if user didn't input any arguments
  14. if (!type || !alias[type]) {
  15. return this.call('help', {_: ['list']});
  16. }
  17. return this.load().then(() => Reflect.apply(store[alias[type]], this, [args]));
  18. }
  19. module.exports = listConsole;