Command Line ArgsIntroduction

Introduction

Parse command-line arguments with type safety, validation, and flexible configuration for Node.js CLI applications.

Last updated:

@visulima/command-line-args

A mature, feature-complete library to parse command-line options with TypeScript support, automatic type conversion, and intuitive API.

Key Features

  • Type-safe parsing - Automatic conversion to String, Number, Boolean
  • Multiple values - Array support for repeated options
  • Aliases - Short (-v) and long (--verbose) option names
  • Default values - Fallback values when options not provided
  • Positional arguments - Capture non-option arguments
  • Flexible parsing - Partial parsing, stop-early modes
  • TypeScript native - Full type definitions included

Quick Start

import { parseArgs } from "@visulima/command-line-args";

const options = parseArgs([
    { name: "file", alias: "f", type: String },
    { name: "verbose", alias: "v", type: Boolean },
    { name: "count", alias: "c", type: Number },
]);

// Usage: node script.js --file input.txt -v --count 5
console.log(options);
// { file: "input.txt", verbose: true, count: 5 }

Use Cases

CLI Tools: Build professional command-line interfaces Build Scripts: Parse configuration flags Development Tools: Create flexible dev tooling Automation: Script with configurable parameters

Support

Contribute to our work and keep us going

Community is the heart of open source. The success of our packages wouldn't be possible without the incredible contributions of users, testers, and developers who collaborate with us every day.Want to get involved? Here are some tips on how you can make a meaningful impact on our open source projects.

Ready to help us out?

Be sure to check out the package's contribution guidelines first. They'll walk you through the process on how to properly submit an issue or pull request to our repositories.

Submit a pull request

Found something to improve? Fork the repo, make your changes, and open a PR. We review every contribution and provide feedback to help you get merged.

Good first issues

Simple issues suited for people new to open source development, and often a good place to start working on a package.
View good first issues