Gathering detailed insights and metrics for cli
Gathering detailed insights and metrics for cli
npm install cli
Typescript
Module System
Min. Node Version
Node Version
NPM Version
98.7
Supply Chain
99.1
Quality
74.6
Maintenance
100
Vulnerability
98.6
License
JavaScript (100%)
Total Downloads
387,027,864
Last Day
137,040
Last Week
633,702
Last Month
2,933,411
Last Year
43,625,515
804 Stars
176 Commits
74 Forks
21 Watching
1 Branches
24 Contributors
Minified
Minified + Gzipped
Latest Version
1.0.1
Package Id
cli@1.0.1
Size
14.23 kB
NPM Version
3.10.8
Node Version
6.9.1
Publised On
23 Oct 2016
Cumulative downloads
Total Downloads
Last day
-7.2%
137,040
Compared to previous day
Last week
-17.8%
633,702
Compared to previous week
Last month
7.5%
2,933,411
Compared to previous month
Last year
-53.4%
43,625,515
Compared to previous year
cli is a toolkit for rapidly building command line apps - it includes:
Install using npm install cli
or just bundle cli.js with your app.
1#!/usr/bin/env node 2require('cli').withStdinLines(function(lines, newline) { 3 this.output(lines.sort().join(newline)); 4});
Try it out
1$ ./sort.js < input.txt
Let's add support for an -n
switch to use a numeric sort, and a -r
switch to reverse output - only 5 extra lines of code (!)
1var cli = require('cli'), options = cli.parse(); 2 3cli.withStdinLines(function(lines, newline) { 4 lines.sort(!options.n ? null : function(a, b) { 5 return parseInt(a) > parseInt(b); 6 }); 7 if (options.r) lines.reverse(); 8 this.output(lines.join(newline)); 9});
cli takes an object as a map for the arguments you wish to parse.
Each property/key in the object is the long version of the argument i.e. --file
The array associated with it is the options to apply to that argument.
1cli.parse({ 2 file: [ 'f', 'A file to process', 'file', temp.log ], // -f, --file FILE A file to process 3 time: [ 't', 'An access time', 'time', false], // -t, --time TIME An access time 4 work: [ false, 'What kind of work to do', 'string', 'sleep' ] // --work STRING What kind of work to do 5});
cli has methods that collect stdin (newline is auto-detected as \n or \r\n)
1cli.withStdin(callback); //callback receives stdin as a string 2cli.withStdinLines(callback); //callback receives stdin split into an array of lines (lines, newline)
cli also has a lower level method for working with input line by line (see ./examples/cat.js for an example).
1cli.withInput(file, function (line, newline, eof) { 2 if (!eof) { 3 this.output(line + newline); 4 } 5});
Note: file
can be omitted if you want to work with stdin
1//cli.toType(object); If a Built-in type, returns the name of the type as a lower cased String 2cli.toType([]); // 'array' 3cli.toType(new Date()); // 'date' 4cli.toType(1); // 'integer' 5cli.toType(1.1); // 'float' 6cli.toType(Math); // 'math' 7cli.toType(/a/); // 'regex' 8cli.toType(JSON); // 'json'
To output a progress bar, call
1cli.progress(progress); //Where 0 <= progress <= 1
To spawn a child process, use
1cli.exec(cmd, callback); //callback receives the output of the process (split into lines)
cli also comes bundled with kof's node-natives (access with cli.native) and creationix' stack (access with cli.createServer)
Plugins are a way of adding common opts and can be enabled using
1cli.enable(plugin1, [plugin2, ...]); //To disable, use the equivalent disable() method
help - enabled by default
Adds -h,--help
to output auto-generated usage information
version
Adds -v,--version
to output version information for the app. cli will attempt to locate and parse a nearby package.json
To set your own app name and version, use cli.setApp(app_name, version)
status
Adds options to show/hide the stylized status messages that are output to the console when using one of these methods
1cli.debug(msg); //Only shown when using --debug 2cli.error(msg); 3cli.fatal(msg); //Exits the process after outputting msg 4cli.info(msg); 5cli.ok(msg);
-k,--no-color
will omit ANSI color escapes from the output
glob - requires npm install glob
Enables glob matching of arguments
timeout
Adds -t,--timeout N
to exit the process after N seconds with an error
catchall
Adds -c,--catch
to catch and output uncaughtExceptions and resume execution
Note: Plugins are automatically disabled if an option or switch of the same name is already defined
(MIT license)
Copyright (c) 2010 Chris O'Hara cohara87@gmail.com
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Stable Version
2
3.5/10
Summary
Duplicate Advisory: Node CLI Allows Arbitrary File Overwrite
Affected Versions
>= 0.1.0, <= 0.11.3
Patched Versions
1.0.0
0/10
Summary
Arbitrary File Write in cli
Affected Versions
< 1.0.0
Patched Versions
1.0.0
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
Found 6/23 approved changesets -- score normalized to 2
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
license 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 2025-01-27
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