Comparing version 0.4.20 to 0.4.21
@@ -41,1 +41,7 @@ 'use strict'; | ||
}; | ||
module.exports.help = { | ||
description: 'Set or display the current working directory', | ||
example: '', | ||
short: null | ||
}; |
'use strict'; | ||
var padRight = require('pad-right'); | ||
var utils = require('../utils'); | ||
var cyan = utils.colors.cyan; | ||
@@ -8,7 +10,3 @@ module.exports = function(app) { | ||
app.debug('command > %s: "%j"', key, val); | ||
console.log('--help is not implemented yet'); | ||
// var commands = help(); | ||
// console.log(commands.options[key]); | ||
// process.exit(0); | ||
console.log(format(help(app._name))); | ||
next(); | ||
@@ -22,60 +20,101 @@ }; | ||
function help() { | ||
function help(appname) { | ||
return { | ||
heading: '', | ||
heading: 'Usage: ' + cyan(appname + ' <command> [options]'), | ||
options: { | ||
init: { | ||
description: 'Force initialization questions to be re-asked.', | ||
ask: { | ||
hide: true, | ||
description: 'this command is not enabled yet', | ||
example: '', | ||
short: 'i' | ||
short: null | ||
}, | ||
help: { | ||
description: '', | ||
choose: { | ||
hide: true, | ||
description: 'this command is not enabled yet', | ||
example: '', | ||
short: 'h' | ||
short: null | ||
}, | ||
show: { | ||
description: '', | ||
config: { | ||
description: 'Save a configuration value to package.json', | ||
example: '--config=toc:false', | ||
short: 'c' | ||
}, | ||
cwd: { | ||
description: 'Set or display the current working directory', | ||
example: '', | ||
short: null | ||
}, | ||
ask: { | ||
description: '', | ||
data: { | ||
description: 'Define data. API equivalent of `app.data()`', | ||
example: '', | ||
short: null | ||
short: 'd' | ||
}, | ||
open: { | ||
description: '', | ||
diff: { | ||
hide: true, | ||
description: 'this command is not enabled yet', | ||
example: '', | ||
short: 'o' | ||
short: null | ||
}, | ||
config: { | ||
description: '', | ||
disable: { | ||
description: 'Disable an option. API equivalent of "app.disable()"', | ||
example: '', | ||
short: 'c' | ||
short: null | ||
}, | ||
diff: { | ||
description: '', | ||
enable: { | ||
description: 'Enable an option. API equivalent of "app.enable()"', | ||
example: '', | ||
short: null | ||
}, | ||
cwd: { | ||
description: '', | ||
global: { | ||
description: 'Save a global configuration value to use as a default', | ||
example: '--global=toc:false', | ||
short: 'g' | ||
}, | ||
help: { | ||
description: 'Display this help menu', | ||
example: '', | ||
short: 'h' | ||
}, | ||
init: { | ||
description: 'Prompts for configuration values and stores the answers', | ||
example: '', | ||
short: 'i' | ||
}, | ||
open: { | ||
description: 'Open the `answers`, `store` or given directory', | ||
command: 'dir', | ||
example: '', | ||
short: null | ||
}, | ||
data: { | ||
description: '', | ||
option: { | ||
description: 'Define options. API equivalent of `app.option()`', | ||
example: '', | ||
short: 'd' | ||
short: 'o' | ||
}, | ||
choose: { | ||
description: '', | ||
run: { | ||
description: 'Force tasks to run regardless of command line flags used', | ||
example: '', | ||
short: null | ||
}, | ||
show: { | ||
description: 'Display the value of <key>', | ||
example: '--show <key>', | ||
command: 'key', | ||
short: null | ||
}, | ||
tasks: { | ||
description: '', | ||
hide: true, | ||
description: 'this command is not enabled yet', | ||
example: '', | ||
short: null | ||
}, | ||
version: { | ||
description: 'Get the current version of ' + appname, | ||
example: '', | ||
short: 'V' | ||
}, | ||
verbose: { | ||
description: 'Display all verbose logging messages', | ||
example: '', | ||
short: 'v' | ||
} | ||
@@ -87,21 +126,30 @@ }, | ||
function format(obj) { | ||
var heading = obj.heading || ''; | ||
function format(help) { | ||
var heading = help.heading || ''; | ||
var options = help.options || {}; | ||
var footer = help.footer || ''; | ||
var optsList = ''; | ||
for (var key in obj) { | ||
if (obj.hasOwnProperty(key)) { | ||
var val = obj[key]; | ||
for (var key in options) { | ||
if (options.hasOwnProperty(key)) { | ||
var val = options[key]; | ||
if (val.hide === true) continue; | ||
if (val.command) { | ||
key += ' <' + val.command + '>'; | ||
} | ||
optsList += toFlag(key, val.short); | ||
optsList += utils.wrap(val.description); | ||
optsList += val.description + '\n'; | ||
} | ||
} | ||
return heading + '\n' | ||
+ optsList + '\n' | ||
+ obj.footer || ''; | ||
var res = '\n' + heading + '\n\n'; | ||
res += optsList + '\n'; | ||
res += footer; | ||
return res; | ||
} | ||
function toFlag(key, short) { | ||
return shortKey(short) + '--' + key + ' '; | ||
function toFlag(key, short, max) { | ||
var str = shortKey(short) + '--' + key; | ||
return padRight(str, 20, ' '); | ||
} | ||
@@ -112,3 +160,1 @@ | ||
} | ||
// console.log(format(help())) |
{ | ||
"name": "base-cli", | ||
"description": "Plugin for base-methods that maps built-in methods to CLI args (also supports methods from a few plugins, like 'base-store', 'base-options' and 'base-data'.", | ||
"version": "0.4.20", | ||
"version": "0.4.21", | ||
"homepage": "https://github.com/jonschlinkert/base-cli", | ||
@@ -44,2 +44,3 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)", | ||
"opn": "^4.0.1", | ||
"pad-right": "^0.2.2", | ||
"project-name": "^0.2.4", | ||
@@ -46,0 +47,0 @@ "question-match": "^0.1.1", |
@@ -378,2 +378,2 @@ # base-cli [![NPM version](https://img.shields.io/npm/v/base-cli.svg)](https://www.npmjs.com/package/base-cli) [![Build Status](https://img.shields.io/travis/jonschlinkert/base-cli.svg)](https://travis-ci.org/jonschlinkert/base-cli) | ||
_This file was generated by [verb](https://github.com/verbose/verb), v0.9.0, on March 04, 2016._ | ||
_This file was generated by [verb](https://github.com/verbose/verb), v0.9.0, on March 05, 2016._ |
44852
1159
27
+ Addedpad-right@^0.2.2
+ Addedpad-right@0.2.2(transitive)