New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

argv

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

argv

CLI Argument Parser

  • 0.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
158K
decreased by-21.23%
Maintainers
1
Weekly downloads
 
Created

What is argv?

The 'argv' npm package is a simple and lightweight library for parsing command-line arguments in Node.js applications. It allows developers to easily access and manipulate command-line arguments passed to their scripts.

What are argv's main functionalities?

Basic Argument Parsing

This feature allows you to parse command-line arguments passed to your Node.js script. The 'argv.run()' method returns an object containing the parsed arguments.

const argv = require('argv');
const args = argv.run();
console.log(args);

Defining Options

This feature allows you to define options for your command-line arguments. You can specify the name, short name, type, description, and example usage for each option.

const argv = require('argv');
argv.option({
  name: 'port',
  short: 'p',
  type: 'int',
  description: 'The port to listen on',
  example: "'script --port=8080' or 'script -p 8080'"
});
const args = argv.run();
console.log(args.options.port);

Handling Commands

This feature allows you to define and handle specific commands. Each command can have its own description and callback function that gets executed when the command is invoked.

const argv = require('argv');
argv.command('start', 'Start the server', function() {
  console.log('Server started');
});
argv.command('stop', 'Stop the server', function() {
  console.log('Server stopped');
});
argv.run();

Other packages similar to argv

Keywords

FAQs

Package last updated on 29 Jan 2023

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