Gathering detailed insights and metrics for noptify
Gathering detailed insights and metrics for noptify
Gathering detailed insights and metrics for noptify
Gathering detailed insights and metrics for noptify
npm install noptify
Module System
Unable to determine the module system for this package.
Min. Node Version
Typescript Support
Node Version
NPM Version
6 Stars
21 Commits
4 Forks
2 Branches
2 Contributors
Updated on 18 May 2014
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-13.4%
12,739
Compared to previous day
Last week
9.2%
87,163
Compared to previous week
Last month
23.9%
328,340
Compared to previous month
Last year
-8%
3,045,242
Compared to previous year
noptify is a little wrapper around nopt
module adding a more expressive,
commander-like, API and few helpers.
Examples
var program = noptify(process.argv, { program: 'name' })
.version('0.0.1')
.option('port', '-p', 'Port to listen on (default: 35729)', Number)
.option('pid', 'Path to the generated PID file', String)
var opts = program.parse();
Returns an instance of Noptify
Noptify provides the API to parse out option, shorthands and generate the proper generic help output.
process.argv
);Every noptify instance is created with two options, -h, --help
and -v, --version
.
Parse the provided options and shorthands, pass them through nopt
and
return the result.
When opts.help
is set, the help output is displayed and help
event is emitted. The process exists with 0
status, the help output is
automatically displayed and the help
event is emitted.
Examples
var program = noptify(['foo', '--help'])
.on('help', function() {
console.log('Examples');
console.log('');
console.log(' foo bar --baz > foo.txt');
});
var opts = program.parse();
// ... Help output ...
// ... Custom help output ...
// ... Exit ...
Define the program version.
Define name
option with optional shorthands, optional description and optional type.
Simply output to stdout the Usage and Help output.
Mocha generated documentation
returns an instanceof Noptify.
1assert.ok(noptify() instanceof noptify.Noptify);
is typically used like so.
1var program = noptify(['node', 'file.js', '-d', '--dirname', './', '-p', '3000', 'app.js', 'base.js']) 2 .option('debug', '-d', 'Enabled debug output', Boolean) 3 .option('dirname', 'The path to the output directory') 4 .option('port', '-p', 'The port you wish to listen on', Number) 5 6// opts => nopt result 7var opts = program.parse(); 8 9assert.deepEqual(opts, { 10 port: 3000, 11 debug: true, 12 dirname: './', 13 argv: { 14 remain: ['app.js', 'base.js'], 15 cooked: ['--debug', '--dirname', './', '--port', '3000', 'app.js', 'base.js'], 16 original: ['-d', '--dirname', './', '-p', '3000', 'app.js', 'base.js'] 17 } 18});
allows definitiion of shorthands separately.
1var opts = noptify(['node', 'file.js', '-lc']) 2 .option('line-comment', 'Ouputs with debugging information', Boolean) 3 .shorthand('lc', '--line-comment') 4 .parse(); 5 6assert.equal(opts['line-comment'], true);
provides the helper method to read from stdin.
1var program = noptify(); 2assert.ok(typeof program.stdin === 'function', 'stdin defined');
is invoked only when .parse() is called.
1var program = noptify(['', '']); 2var str = 'testing out stdin helper'; 3program.stdin(function(err, res) { 4 assert.equal(res, str); 5 done(); 6}); 7 8program.parse(); 9 10process.nextTick(function() { 11 process.stdin.emit('data', str); 12 process.stdin.emit('end'); 13});
provides the .command() utility.
1assert.ok(typeof noptify().command === 'function');
can be a simple function.
1var program = noptify(['', '', 'init', '--debug', 'foo']).option('debug', 'an option'); 2 3program.command('init', function(args, opts) { 4 // args ==> sliced args at command position 5 // opts ==> nopt parsed object 6 assert.deepEqual(args, ['--debug', 'foo']); 7 assert.equal(opts.debug, true); 8 assert.equal(opts.argv.remain[0], 'foo'); 9 done(); 10}); 11 12program.parse();
or another program, an Noptify instance.
1var args = ['', '', 'init', '--debug', 'myapp', 'foo']; 2 3var init = noptify(args) 4 .option('debug', 'Debug output') 5 .command('myapp', done.bind(null, null)); 6 7noptify(args).command('init', init).parse();
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 1/21 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More