Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
simpleargumentsparser
Advanced tools
A simple library to parse cli arguments. Perfect to make commands
You can make your own even simplier parser adapted exactly to your code requeriments. But using this library, you can save a lot of time.
Writing custom parsers like i was doing for each command, takes a good amount of time. More even on simpler ones. Just better throw a npm install, a require await the parser and you ready to go.
I created this library because i don't like any of other command parsers i tryied. Some are to basic, others are to bug for a simple parsing, others just don't work well and other are to complicated.
I probably will be using this library from now. So i will be finding and fixing errors, improving the code, etc. It's going to get much better.
npm i simpleargumentsparser
Arguments are short to reduce time programming.
const CLI = {
s: {}, // single
c: {}, // couple
o: [], // other
p: {}, // pipped
e: [], // end
noArgs: false,
argc: process.argv.length - 2
};
$ helloworld -n Manolo -vd
s: { n: "Manolo", v: true, d: true }
$ helloworld --name String --last-name Manolo --verbose
c: { name: "String", 'last-name': "Manolo", verbose: true }
$ helloworld hello how are you
o: [ [ "hello", 1 ], [ "how", 2 ], [ "are", 3 ], [ "you", 4 ] ]
$ echo "Hey!" | helloworld -n Manolo
p: "Hey!",
s: { n: 'Manolo' }
$ helloworld -v -- helloworld2 -v -- helloworld3 -v
e: [ 2, 5 ]
noArgs is just a boolean set to true if no arguments provided
If pipped is provided, noArgs will remain to false
argc counts the number of arguments
argc doesn't count pipped as an argument
const parseCLI = require("simpleargumentsparser");
(async() => {
const cli = await parseCLI();
let verbose = false;
if (cli.noArgs) exit("Arguments needed");
if (cli.s.h || cli.c.help) exit("Help Menu:\n\nThis is just an example");
if (cli.s.v || cli.c.verbose) verbose = true;
if (cli.c.version) exit("V0.0.1");
if (cli.s.s) console.log("Hello!");
if (cli.p) console.log("Hello", cli.p);
if (cli.c?.["debug-arguments"]) console.log(JSON.stringify(cli, null, 4));
})();
const exit = msg => {
console.log(msg);
process.exit(0);
}
FAQs
Parse CLI arguments from node
The npm package simpleargumentsparser receives a total of 0 weekly downloads. As such, simpleargumentsparser popularity was classified as not popular.
We found that simpleargumentsparser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.