yargs
Build interactive command-line tools by parsing arguments and generating an elegant user interface.
yargs
General JSBuild interactive command-line tools by parsing arguments and generating an elegant user interface.
Fit
Bundle (gzip)
31.9 kB
107.9 kB raw
Install size includes transitive dependencies. Bundle size is gzipped browser payload.
Freshness
The Problem
Parsing process.argv by hand quickly becomes messy once a CLI needs subcommands, typed options, defaults, validation, and auto-generated help text.
What It Does
yargs turns argument parsing into a declarative API with commands, options, coercion, and validation, and automatically produces --help and --version output. It is a core dependency of countless CLI tools.
Installation
npm install yargsUsage Example
import yargs from "yargs";
import { hideBin } from "yargs/helpers";
yargs(hideBin(process.argv))
.command(
"greet <name>",
"greet a user",
(y) => y.positional("name", { type: "string" }),
(argv) => console.log(`Hello, ${argv.name}!`)
)
.option("loud", { type: "boolean", default: false })
.help()
.parse();Related packages
Unified TypeScript SDK for building AI-powered apps — switch between 20+ LLM providers without rewriting code.
animejsGeneral JSLightweight JavaScript animation library with a tiny footprint and a powerful, expressive API.
AOSGeneral JSAn easy-to-use library that makes elements fade, slide, or zoom into view as the user scrolls down your page.
archiverGeneral JSStreaming interface for generating ZIP and TAR archives in Node.js — create compressed archives programmatically from files, directories, and buffers.
@formkit/auto-animateGeneral JS> Add smooth transitions to any element with a single line — zero-config animations for adds, removes, and moves.