Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
@types/yargs
Advanced tools
The @types/yargs package provides TypeScript type definitions for the yargs library, which is a tool to help build interactive command line tools, by parsing arguments and generating an elegant user interface. It helps TypeScript developers to have auto-completion and type checking when using yargs.
Command Module Definition
Defines a command with options. This example creates a 'get' command with a required 'url' option.
import * as yargs from 'yargs';
yargs.command('get', 'make a get HTTP request', {
url: {
describe: 'URL to make request to',
demand: true,
alias: 'u',
type: 'string'
}
}, (argv) => {
console.log(`Making a GET request to: ${argv.url}`);
});
Option Parsing
Parses command line options. This example parses a boolean 'verbose' option.
import * as yargs from 'yargs';
const argv = yargs.option('verbose', {
alias: 'v',
type: 'boolean',
description: 'Run with verbose logging'
}).argv;
if (argv.verbose) console.log('Verbose mode on');
Help and Version Setup
Sets up automatic version and help message support. This example sets the version of the CLI tool and enables the default help support.
import * as yargs from 'yargs';
yargs.version('1.0.0').help().argv;
Commander is another popular npm package for building command line interfaces. It offers a high-level API for creating commands and options, similar to yargs. Commander is known for its simplicity and ease of use, but yargs provides more detailed control over argument parsing and generates more comprehensive help messages automatically.
Meow is a lighter alternative to yargs for building CLI tools. It focuses on simplicity and minimal configuration. While it is easier to set up for simple scripts, yargs offers more advanced features like command-specific options, middleware, and automatic help generation.
npm install --save @types/yargs
This package contains type definitions for yargs (https://github.com/chevex/yargs).
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/yargs/v12.
These definitions were written by Martin Poelstra, Mizunashi Mana, Jeffery Grajkowski, Jimi (Dimitris) Charalampidis, Steffen Viken Valvåg, Emily Marigold Klassen, and ExE Boss.
FAQs
TypeScript definitions for yargs
The npm package @types/yargs receives a total of 54,095,144 weekly downloads. As such, @types/yargs popularity was classified as popular.
We found that @types/yargs demonstrated a healthy version release cadence and project activity because the last version was released less than 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
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.