New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

sergeant

Package Overview
Dependencies
Maintainers
1
Versions
142
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sergeant - npm Package Compare versions

Comparing version 15.4.15 to 15.5.0

100

help.js

@@ -10,2 +10,8 @@ const chalk = require('chalk')

if (description) {
console.error('')
console.error(description)
}
Object.keys(definitions).forEach(function (key) {

@@ -31,14 +37,38 @@ const definition = definitions[key]

if (parameterKeys.length || optionKeys.length) {
console.error(chalk.green('Usage:') + ' ' + name + ' [options] ' + parameterKeys.map((key) => (definitions[key].multiple === true ? '...' : '') + definitions[key].signature).join(' '))
let usage = [name]
if (optionKeys.length) {
usage = usage.concat(optionKeys.map((key) => {
const definition = definitions[key]
return (definition.required !== true ? '[' : '') + definition.signature + (definition.type !== Boolean ? '=' + '<' + (definition.type ? definition.type.name : key) + '>' : '') + (definition.multiple === true ? '...' : '') + (definition.required !== true ? ']' : '')
}))
}
if (parameterKeys.length) {
usage = usage.concat(parameterKeys.map((key) => {
const definition = definitions[key]
return (definition.required !== true ? '[' : '') + '<' + definition.signature + '>' + (definition.multiple === true ? '...' : '') + (definition.required !== true ? ']' : '')
}))
}
console.error('')
}
if (description) {
console.error(description)
if (Object.keys(commands).length) {
console.error(chalk.green('Usage:'))
console.error('')
console.error('')
console.error(usage.join(' '))
console.error(name + ' <command> [--help,-h]')
} else {
console.error(chalk.green('Usage:') + ' ' + usage.join(' '))
}
}
if (parameterKeys.length) {
console.error('')
console.error(chalk.green('Parameters:'))

@@ -56,12 +86,19 @@

const definition = definitions[key]
const description = [' '.repeat(longestParameter - definition.signature.length) + definition.signature]
const details = describe(definition)
if (definition.description) {
description.push(chalk.gray(definition.description))
}
console.error(' '.repeat(longestParameter - definition.signature.length) + definition.signature + ' ' + details)
if (definition.default) {
description.push('[default: ' + (typeof definition.default === 'string' ? '"' : '') + definition.default + (typeof definition.default === 'string' ? '"' : '') + ']')
}
console.error(description.join(' '))
})
}
if (optionKeys.length) {
console.error('')
}
if (optionKeys.length) {
console.error(chalk.green('Options:'))

@@ -79,9 +116,14 @@

const definition = definitions[key]
const description = [' '.repeat(longestOption - definition.signature.length) + definition.signature]
const details = describe(definition)
if (definition.description) {
description.push(chalk.gray(definition.description))
}
console.error(' '.repeat(longestOption - definition.signature.length) + definition.signature + ' ' + details)
if (definition.default) {
description.push('[default: ' + (typeof definition.default === 'string' ? '"' : '') + definition.default + (typeof definition.default === 'string' ? '"' : '') + ']')
}
console.error(description.join(' '))
})
console.error('')
}

@@ -96,2 +138,4 @@

console.error('')
console.error(chalk.green('Commands:'))

@@ -104,33 +148,5 @@

console.error(name + ' ' + key + ' ' + ' '.repeat(longestCommand - key.length) + chalk.gray(command.description != null ? command.description : ''))
console.error(key + (command.description ? ' ' + ' '.repeat(longestCommand - key.length) + chalk.gray(command.description != null ? command.description : '') : ''))
})
console.error('')
}
}
function describe (definition) {
let details = []
if (definition.description != null) {
details.push(definition.description)
}
if (definition.default != null) {
details.push('Default: ' + definition.default)
}
if (definition.type != null && definition.type.name != null) {
details.push('Type: ' + definition.type.name)
}
if (definition.required === true) {
details.push('Required')
}
if (definition.multiple === true) {
details.push('Multiple')
}
return chalk.gray(details.join('. '))
}
{
"name": "sergeant",
"version": "15.4.15",
"version": "15.5.0",
"description": "",

@@ -5,0 +5,0 @@ "main": "main.js",

@@ -16,10 +16,10 @@ const test = require('tape')

// test dashdash and parameter
t.deepEquals(parse(['--', '-a'], {
t.deepEquals({'test': '-a'}, parse(['--', '-a'], {
'0': {
key: 'test'
}
}), {'test': '-a'})
}))
// test dashdash and parameter with type
t.deepEquals(parse(['--', '123'], {
t.deepEquals({'test': 123}, parse(['--', '123'], {
'0': {

@@ -29,16 +29,16 @@ type: Number,

}
}), {'test': 123})
}))
// test non-required parameter
t.deepEquals(parse([], {
t.deepEquals({}, parse([], {
'0': {
key: 'test'
}
}), {})
}))
// test empty
t.deepEquals(parse([''], {}), {})
t.deepEquals({}, parse([''], {}))
// test short
t.deepEquals(parse(['-a'], {
t.deepEquals({aaA: true}, parse(['-a'], {
'aa-a': {

@@ -48,13 +48,13 @@ type: Boolean,

}
}), {aaA: true})
}))
// test short with value
t.deepEquals(parse(['-a=bcd'], {
t.deepEquals({aaA: 'bcd'}, parse(['-a=bcd'], {
'aa-a': {
aliases: ['a']
}
}), {aaA: 'bcd'})
}))
// test multiple short with value
t.deepEquals(parse(['-ba=bcd'], {
t.deepEquals({aaA: 'bcd', b: true}, parse(['-ba=bcd'], {
'aa-a': {

@@ -66,6 +66,6 @@ aliases: ['a']

}
}), {aaA: 'bcd', b: true})
}))
// test multiple short
t.deepEquals(parse(['-ba'], {
t.deepEquals({aaA: true, b: true}, parse(['-ba'], {
'aa-a': {

@@ -78,6 +78,6 @@ type: Boolean,

}
}), {aaA: true, b: true})
}))
// test multiple, ---, and -
t.deepEquals(parse(['-a', 'bcd', '-a', '---', '-a', '-'], {
t.deepEquals({aaA: ['bcd', '---', '-']}, parse(['-a', 'bcd', '-a', '---', '-a', '-'], {
'aa-a': {

@@ -87,6 +87,6 @@ multiple: true,

}
}), {aaA: ['bcd', '---', '-']})
}))
// test non-empty default
t.deepEquals(parse(['-a'], {
t.deepEquals({aaA: ''}, parse(['-a'], {
'aa-a': {

@@ -96,6 +96,6 @@ aliases: ['a'],

}
}), {aaA: ''})
}))
// test default with equals
t.deepEquals(parse(['--aa-a='], {
t.deepEquals({aaA: ''}, parse(['--aa-a='], {
'aa-a': {

@@ -105,6 +105,6 @@ aliases: ['a'],

}
}), {aaA: ''})
}))
// test default parameter
t.deepEquals(parse(['testing'], {
t.deepEquals({'0': 'testing', '1': 'yes'}, parse(['testing'], {
'0': {

@@ -115,6 +115,7 @@ },

}
}), {'0': 'testing', '1': 'yes'})
}))
// test multiple param beginning
t.deepEquals(parse(['1', '2', '3', '4', '5', '6', '7', '8', '9'], {
t.deepEquals({'test0': [1, 2, 3, 4, 5, 6, 7], 'test1': 8, 'test2': 9},
parse(['1', '2', '3', '4', '5', '6', '7', '8', '9'], {
'0': {

@@ -133,6 +134,7 @@ type: Number,

}
}), {'test0': [1, 2, 3, 4, 5, 6, 7], 'test1': 8, 'test2': 9})
}))
// test multiple param middle. No type
t.deepEquals(parse(['1', '2', '3', '4', '5', '6', '7', '8', '9'], {
t.deepEquals({'test0': 1, 'test1': ['2', '3', '4', '5', '6', '7', '8'], 'test2': 9},
parse(['1', '2', '3', '4', '5', '6', '7', '8', '9'], {
'0': {

@@ -150,6 +152,7 @@ type: Number,

}
}), {'test0': 1, 'test1': ['2', '3', '4', '5', '6', '7', '8'], 'test2': 9})
}))
// test multiple param end
t.deepEquals(parse(['1', '2', '3', '4', '5', '6', '7', '8', '9'], {
t.deepEquals({'test0': 1, 'test1': 2, 'test2': [3, 4, 5, 6, 7, 8, 9]},
parse(['1', '2', '3', '4', '5', '6', '7', '8', '9'], {
'0': {

@@ -168,3 +171,3 @@ type: Number,

}
}), {'test0': 1, 'test1': 2, 'test2': [3, 4, 5, 6, 7, 8, 9]})
}))
})

@@ -239,5 +242,5 @@

t.equals(1, globals.process.exitCode)
t.equals(globals.process.exitCode, 1)
t.deepEquals(messages, [
t.deepEquals([
chalk.red('-a is a boolean and does not accept a value'),

@@ -251,3 +254,3 @@ chalk.red('--aaa is a boolean and does not accept a value'),

chalk.red('too many arguments')
])
].join('\n'), messages.join('\n'))

@@ -325,41 +328,44 @@ mockery.disable()

t.equals(1, globals.process.exitCode)
t.equals(globals.process.exitCode, 1)
t.deepEquals(messages, [
chalk.green('Usage:') + ' test-command [options] ...p0 p1',
t.deepEquals([
'',
chalk.green('Usage:') + ' test-command [--aaa,--aa,-a...] [-b=<Number>] <p0>... [<p1>]',
'',
chalk.green('Parameters:'),
'',
'p0 ' + chalk.gray('Required. Multiple'),
'p1 ' + chalk.gray('Default: a default'),
'p0',
'p1 ' + chalk.gray('[default: "a default"]'),
'',
chalk.green('Options:'),
'',
' --aaa,--aa,-a ' + chalk.gray('a Boolean. Type: Boolean. Multiple'),
' -b ' + chalk.gray('a Number. Type: Number'),
' --aaa,--aa,-a ' + chalk.gray('a Boolean'),
' -b ' + chalk.gray('a Number'),
'',
chalk.green('Usage:') + ' test-command [options] p0',
'',
'a test command',
'',
chalk.green('Usage:'),
'',
'test-command <p0>',
'test-command <command> [--help,-h]',
'',
chalk.green('Parameters:'),
'',
'p0 ' + chalk.gray('Required'),
'p0',
'',
chalk.green('Commands:'),
'',
'test-command sub-command-b ' + chalk.gray(''),
'test-command sub-command ' + chalk.gray('a sub command'),
'sub-command-b',
'sub-command ' + chalk.gray('a sub command'),
'',
chalk.green('Usage:') + ' test-command [options] ',
'',
'a test command',
'',
chalk.green('Usage:') + ' test-command [--aaa,--aa,-a...]',
'',
chalk.green('Options:'),
'',
' --aaa,--aa,-a ' + chalk.gray('a Boolean. Type: Boolean. Multiple'),
' --aaa,--aa,-a ' + chalk.gray('a Boolean'),
'',
'a test command',
''
])
'a test command'
].join('\n'), messages.join('\n'))

@@ -401,5 +407,5 @@ mockery.disable()

t.equals(1, globals.process.exitCode)
t.equals(globals.process.exitCode, 1)
t.deepEquals(messages, [
t.deepEquals([
chalk.red('testing errors'),

@@ -409,3 +415,3 @@ chalk.gray('at thing ') + '(file.js:123:45)',

chalk.red('testing errors')
])
].join('\n'), messages.join('\n'))

@@ -425,5 +431,5 @@ mockery.disable()

function mockedParse (argv, definitions) {
t.deepEquals(argv, ['testing'])
t.deepEquals(['testing'], argv)
t.deepEquals(definitions, {
t.deepEquals({
'0': {

@@ -441,3 +447,3 @@ key: 'aaa',

}
})
}, definitions)

@@ -484,5 +490,5 @@ return {}

function mockedHelp (name, description, definitions) {
t.equals(name, 'test-command')
t.equals('test-command', name)
t.deepEquals(definitions, {
t.deepEquals({
'0': {

@@ -500,3 +506,3 @@ key: 'aaa',

}
})
}, definitions)
}

@@ -538,3 +544,3 @@

function mockedError (error) {
t.deepEquals(error, ourError)
t.deepEquals(ourError, error)
}

@@ -571,3 +577,3 @@

function mockedError (error) {
t.deepEquals(error, ourError)
t.deepEquals(ourError, error)
}

@@ -574,0 +580,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc