diff --git a/lib/actions/help.js b/lib/actions/help.js index d056e4f8..22559fa2 100644 --- a/lib/actions/help.js +++ b/lib/actions/help.js @@ -106,7 +106,7 @@ help.argumentsHelp = function argumentsHelp() { return [ '', config.name ? config.name : '', - config.desc ? '# ' + config.desc : '', + config.description ? '# ' + config.description : '', config.type ? 'Type: ' + config.type.name : '', 'Required: ' + config.required ]; @@ -125,14 +125,12 @@ help.optionsHelp = function optionsHelp() { }); var rows = options.map(function (opt) { - var defaults = opt.default; - return [ '', opt.alias ? '-' + opt.alias + ', ' : '', '--' + opt.name, - opt.desc ? '# ' + opt.desc : '', - defaults == null || defaults === '' ? '' : 'Default: ' + defaults + opt.description ? '# ' + opt.description : '', + opt.default != null && opt.default !== '' ? 'Default: ' + opt.default : '' ]; }); diff --git a/lib/index.js b/lib/index.js index 3469e0f2..8673b660 100644 --- a/lib/index.js +++ b/lib/index.js @@ -73,18 +73,18 @@ var Base = module.exports = function Base(args, options) { this.option('help', { alias: 'h', - desc: 'Print the generator\'s options and usage' + description: 'Print the generator\'s options and usage' }); this.option('skip-cache', { type: Boolean, - desc: 'Do not remember prompt answers', + description: 'Do not remember prompt answers', default: false }); this.option('skip-install', { type: Boolean, - desc: 'Do not automatically install dependencies', + description: 'Do not automatically install dependencies', default: false }); @@ -179,7 +179,7 @@ Base.prototype.prompt = function (questions) { * * ### Options: * - * - `desc` Description for the option + * - `description` Description for the option * - `type` Either Boolean, String or Number * - `alias` Option name alias (example `-h` and --help`) * - `default` Default value @@ -191,11 +191,15 @@ Base.prototype.prompt = function (questions) { Base.prototype.option = function option(name, config) { config = config || {}; + + // alias default to defaults for backward compatibility. + config.default = config.default != null ? config.default : config.defaults; + config.description = config.description || config.desc; + _.defaults(config, { name: name, - desc: 'Description for ' + name, + description: 'Description for ' + name, type: Boolean, - default: config.defaults, hide: false }); @@ -219,7 +223,7 @@ Base.prototype.option = function option(name, config) { * * ### Options: * - * - `desc` Description for the argument + * - `description` Description for the argument * - `required` Boolean whether it is required * - `optional` Boolean whether it is optional * - `type` String, Number, Array, or Object @@ -233,7 +237,8 @@ Base.prototype.argument = function argument(name, config) { config = config || {}; // alias default to defaults for backward compatibility. - config.default = config.default || config.defaults; + config.default = config.default != null ? config.default : config.defaults; + config.description = config.description || config.desc; _.defaults(config, { name: name, diff --git a/test/base.js b/test/base.js index 7118a66a..e73ae9e7 100644 --- a/test/base.js +++ b/test/base.js @@ -658,7 +658,7 @@ describe('Base', function () { generator.option('foo'); assert.deepEqual(generator._options.foo, { - desc: 'Description for foo', + description: 'Description for foo', name: 'foo', type: Boolean, default: undefined,