Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

args

Package Overview
Dependencies
Maintainers
2
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

args

Minimal toolkit for building CLIs

  • 5.0.3
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.9M
increased by26.59%
Maintainers
2
Weekly downloads
 
Created

What is args?

The 'args' npm package is a lightweight library for parsing command-line arguments in Node.js applications. It provides a simple and intuitive API for defining and handling command-line options and arguments.

What are args's main functionalities?

Basic Argument Parsing

This feature allows you to define and parse basic command-line arguments. In this example, the 'name' option is defined, and the parsed value is used to print a greeting message.

const args = require('args');
args.option('name', 'Your name');
const flags = args.parse(process.argv);
console.log(`Hello, ${flags.name}!`);

Default Values

You can set default values for options. If the user does not provide a value for the 'name' option, 'Anonymous' will be used as the default.

const args = require('args');
args.option('name', 'Your name', 'Anonymous');
const flags = args.parse(process.argv);
console.log(`Hello, ${flags.name}!`);

Command Handling

The 'args' package supports defining commands. In this example, a 'greet' command is defined, which takes a name as an argument and prints a greeting message.

const args = require('args');
args.command('greet', 'Greet someone', (name) => {
  console.log(`Hello, ${name}!`);
});
args.parse(process.argv, { name: 'greet' });

Help Messages

The package can automatically generate help messages and usage examples. This example shows how to define an example usage for the 'name' option.

const args = require('args');
args.option('name', 'Your name');
args.example('node script.js --name John', 'Greet John');
args.parse(process.argv);

Other packages similar to args

Keywords

FAQs

Package last updated on 01 May 2022

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc