index.js 582 B

123456789101112131415161718192021222324252627
  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. const self = this;
  14. // Display help message if user didn't input any arguments
  15. if (!type || !alias[type]) {
  16. return this.call('help', {_: ['list']});
  17. }
  18. return this.load().then(() => store[alias[type]].call(self, args));
  19. }
  20. module.exports = listConsole;