diff --git a/lib/plugins/console/index.js b/lib/plugins/console/index.js index 95db937661..ddd81fc15a 100644 --- a/lib/plugins/console/index.js +++ b/lib/plugins/console/index.js @@ -42,7 +42,7 @@ module.exports = function(ctx) { desc: 'List the information of the site.', usage: '', arguments: [ - {name: 'type', desc: 'Available types: page, post, route, tag, category(cate)'} + {name: 'type', desc: 'Available types: page, post, route, tag, category'} ] }, require('./list')); diff --git a/lib/plugins/console/list/index.js b/lib/plugins/console/list/index.js index 1bc5fd3df4..f915d24e79 100644 --- a/lib/plugins/console/list/index.js +++ b/lib/plugins/console/list/index.js @@ -1,26 +1,28 @@ 'use strict'; +var abbrev = require('abbrev'); + var store = { page: require('./page'), post: require('./post'), route: require('./route'), tag: require('./tag'), - category: require('./category'), - // the alias of category - cate: require('./category') + category: require('./category') }; +var alias = abbrev(Object.keys(store)); + function listConsole(args) { var type = args._.shift(); var self = this; // Display help message if user didn't input any arguments - if (!type || !store.hasOwnProperty(type)) { + if (!type || !alias[type]) { return this.call('help', {_: ['list']}); } return this.load().then(function() { - return store[type].call(self, args); + return store[alias[type]].call(self, args); }); }