Comparing version 24.1.0 to 24.1.1
12
help.js
@@ -6,6 +6,6 @@ const {green} = require('kleur') | ||
const getUsage = (title, {options, parameters}) => { | ||
let usage = ['', title] | ||
const usage = ['', title] | ||
if (options && options.length) { | ||
usage = usage.concat(options.map((definition) => { | ||
usage.push(...options.map((definition) => { | ||
const valPart = definition.type != null | ||
@@ -20,3 +20,3 @@ ? ` <${definition.key}>` | ||
if (parameters && parameters.length) { | ||
usage = usage.concat(parameters.map((definition) => wrapUsage(`<${definition.key}>`, definition))) | ||
usage.push(...parameters.map((definition) => wrapUsage(`<${definition.key}>`, definition))) | ||
} | ||
@@ -83,4 +83,6 @@ | ||
const longestArg = longest(parameters.map((definition) => `<${definition.key}>`) | ||
.concat(options.map((definition) => getOptionSignature(definition)))) | ||
const longestArg = longest([ | ||
...parameters.map((definition) => `<${definition.key}>`), | ||
...options.map((definition) => getOptionSignature(definition)) | ||
]) | ||
@@ -87,0 +89,0 @@ if (parameters.length) { |
@@ -61,3 +61,3 @@ const parse = require('./parse') | ||
cli.commands.push(sergeant(path.split(' ').concat([subtitle]).join(' '), description, define)) | ||
cli.commands.push(sergeant(`${path} ${subtitle}`, description, define)) | ||
} | ||
@@ -64,0 +64,0 @@ |
{ | ||
"name": "sergeant", | ||
"version": "24.1.0", | ||
"version": "24.1.1", | ||
"description": "", | ||
@@ -21,10 +21,10 @@ "main": "index.js", | ||
"devDependencies": { | ||
"@erickmerchant/lint": "^1.7.0", | ||
"@erickmerchant/lint": "^1.10.1", | ||
"outdent": "^0.7.0", | ||
"proxyquire": "^2.1.0", | ||
"tape": "^4.9.2" | ||
"tape": "^4.10.0" | ||
}, | ||
"dependencies": { | ||
"kleur": "^3.0.1" | ||
"kleur": "^3.0.2" | ||
} | ||
} |
12
parse.js
@@ -42,10 +42,10 @@ const {red} = require('kleur') | ||
if (arg.indexOf('=') > -1) { | ||
argv.push(`-${arg.substr(arg.indexOf('=') - 1)}`) | ||
argv.push(`-${arg.substring(arg.indexOf('=') - 1)}`) | ||
arg = arg.substring(1, arg.indexOf('=') - 1) | ||
} else { | ||
arg = arg.substr(1) | ||
arg = arg.substring(1) | ||
} | ||
argv = argv.concat(arg.split('').map((arg) => `-${arg}`)) | ||
argv.push(...arg.split('').map((arg) => `-${arg}`)) | ||
} else { | ||
@@ -81,3 +81,3 @@ argv.push(arg) | ||
} else if (isSearchWithValue && !isBoolean) { | ||
vals.push(argv[i].substr(argv[i].indexOf('=') + 1)) | ||
vals.push(argv[i].substring(argv[i].indexOf('=') + 1)) | ||
@@ -93,3 +93,3 @@ toBeDeleted.push(i) | ||
if (definition.multiple === true) { | ||
args[property] = args[property] != null ? args[property].concat(vals) : vals | ||
args[property] = args[property] != null ? [...args[property], ...vals] : vals | ||
} else if (args[property] != null) { | ||
@@ -140,3 +140,3 @@ throw new Error(`${addDashes(definition.key)} does not accept multiple values`) | ||
const remainder = argv.concat(afterDashDash).filter((arg) => arg !== '') | ||
const remainder = [...argv, ...afterDashDash].filter((arg) => arg !== '') | ||
@@ -143,0 +143,0 @@ const hasMultiple = parameters.filter((definition) => definition.multiple).length > 0 |
@@ -11,2 +11,12 @@ # sergeant | ||
const say = (name, loud = false) => { | ||
let message = `hello ${name}!` | ||
if (loud) { | ||
message = message.toUpperCase() + '!' | ||
} | ||
console.log(message) | ||
} | ||
command('hello', ({option, parameter, command}) => { | ||
@@ -40,13 +50,2 @@ parameter('name', { | ||
})(process.argv.slice(2)) | ||
function say (name, loud = false) { | ||
let message = `hello ${name}!` | ||
if (loud) { | ||
message = message.toUpperCase() + '!' | ||
} | ||
console.log(message) | ||
} | ||
``` | ||
@@ -53,0 +52,0 @@ |
@@ -9,3 +9,3 @@ const addDashes = (key) => (key.length === 1 ? '-' : '--') + key | ||
const split = key.split('-').filter((part) => part !== '') | ||
const property = split[0] + split.slice(1).map((part) => part.substr(0, 1).toUpperCase() + part.substr(1)).join('') | ||
const property = split[0] + split.slice(1).map((part) => part.substring(0, 1).toUpperCase() + part.substring(1)).join('') | ||
@@ -12,0 +12,0 @@ return property |
970
28991
60
Updatedkleur@^3.0.2