Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Package description
The mri npm package is a lightweight option parsing library. It allows for easy parsing of command-line options, providing a simple API to access command-line arguments in a structured way. It's designed for performance and simplicity, making it a great choice for projects that require basic yet efficient argument parsing without the overhead of more complex libraries.
Basic Option Parsing
This code demonstrates how to parse command-line arguments using mri. It slices the process.argv array to ignore the first two entries (node path and script path), then parses the remaining arguments into an options object.
const mri = require('mri');
const args = process.argv.slice(2);
const options = mri(args);
console.log(options);
Specifying Option Types
This example shows how to specify the types of options (boolean, string) and aliases for them. This helps in parsing the command-line arguments more accurately according to the expected types and aliases.
const mri = require('mri');
const args = process.argv.slice(2);
const cliOptions = {
boolean: ['help', 'version'],
string: ['output'],
alias: { h: 'help', v: 'version', o: 'output' }
};
const options = mri(args, cliOptions);
console.log(options);
Yargs is a more feature-rich command-line option parsing library compared to mri. It offers advanced features like command handling, automatic help generation, and more detailed option configurations. While mri focuses on simplicity and performance, yargs provides a broader set of functionalities for complex CLI applications.
Commander is another popular option parsing library that provides a high-level API for creating command-line interfaces. It supports subcommands, custom help, auto-completion, and more. Compared to mri, Commander is suited for more complex CLI applications that require structured commands and options.
Minimist is a minimalist option parsing library similar to mri in terms of simplicity and performance. It provides basic parsing capabilities with a focus on minimal overhead. While mri and minimist share similar goals, mri offers a slightly more modern API and additional features like option type specification.
Readme
Quickly scan for CLI flags and arguments
This is a very basic, fast, and lightweight alternative to minimist
. It only exists because I find that I usually don't need most of what minimist
has to offer.
For now, there's no configuration options. Instead, mri
just parses raw CLI flags (single or group) and assigns a value to those keys.
Note: Defaults, aliases, and type-casting are not supported. However, this may change in the future. :thinking:
$ npm install --save mri
$ demo-cli --foo --bar=baz -mtv -- hello world
const mri = require('mri');
const args = process.argv.slice(2);
mri(args);
//=> { _: ['hello', 'world'], foo:true, bar:'baz', m:true, t:true, v:true }
Type: array
Default: []
An array of arguments to parse. For CLI usage, send process.argv.slice(2)
. See process.argv
for info.
MIT © Luke Edwards
FAQs
Quickly scan for CLI flags and arguments
The npm package mri receives a total of 6,377,986 weekly downloads. As such, mri popularity was classified as popular.
We found that mri 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.