Skip to content

Commit

Permalink
Add abbrev. support for list console
Browse files Browse the repository at this point in the history
  • Loading branch information
tommy351 committed Nov 7, 2015
1 parent 5583b4d commit 40ccecb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/plugins/console/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ module.exports = function(ctx) {
desc: 'List the information of the site.',
usage: '<type>',
arguments: [
{name: 'type', desc: 'Available types: page, post, route, tag, category(cate)'}
{name: 'type', desc: 'Available types: page, post, route, tag, category'}
]
}, require('./list'));

Expand Down
12 changes: 7 additions & 5 deletions lib/plugins/console/list/index.js
Original file line number Diff line number Diff line change
@@ -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);
});
}

Expand Down

0 comments on commit 40ccecb

Please sign in to comment.