jackspeak
A very strict and proper argument parser.
USAGE
const { jack, flag, opt, list, count } = require('jackspeak')
jack({
main: myFunction,
argv: process.argv,
usage: 'foo [options] <files>',
help: `
Executes all the files and interprets their output as
TAP formatted test result data.
To parse TAP data from stdin, specify "-" as a filename.
`
flag: flag({
short: 'f',
description: `Make the flags wave`,
negate: {
short: 'F',
description: `Do not wave the flags`
},
default: true
}),
jobs: opt({
short: 'j',
description: 'number of jobs to run in parallel',
default: 1
}),
'jobs-auto': flag({
short: 'J',
alias: '--jobs=' + require('os').cpus().length
}),
timeout: opt({
short: 't',
default: +process.env.TAP_TIMEOUT || 30,
}),
'no-timeout': flag({
short: 'T',
alias: '--timeout=0'
}),
'node-arg': list(),
debug: count({
short: 'd'
})
foo: flag({
alias: ['--statements=100', '--lines=100', '--branches=100'],
}),
covlevel: opt({
alias: ['--statements=${value}', '--lines=${value}', '--branches=${value}]
}),
// aliases can recurse, as well
100: flag({
alias: '--covlevel=100'
}),
// opts take a value, and is set to the string in the results
// you can combine multiple short-form flags together, but
// an opt will end the combine chain, posix-style. So,
// -bofilename would be like --bail --output-file=filename
'output-file': opt({
short: 'o',
// optional: make it -o<file> in the help output insead of -o<value>
hint: 'file',
description: `Send the raw output to the specified file.`
}),
})
Name
The inspiration for this module is yargs, which
is pirate talk themed. Yargs has all the features, and is infinitely
flexible. "Jackspeak" is the slang of the royal navy. This module
does not have all the features, and is rigid by design.