Command Line ArgsAPI Reference

API Reference

Complete API documentation for @visulima/command-line-args.

Last updated:

API Reference

Functions

parseArgs(definitions, options?)

Parse command-line arguments.

Parameters:

  • definitions (OptionDefinition[]): Option definitions
  • options (ParseOptions, optional): Parsing options

Returns: Parsed options object

commandLineArgs(definitions, options?)

Alias for parseArgs() (backward compatibility).

Types

OptionDefinition

interface OptionDefinition {
    name: string;                // Option name
    alias?: string;              // Short alias
    type?: TypeConstructor;      // String, Number, Boolean
    defaultValue?: any;          // Default value
    multiple?: boolean;          // Allow multiple values
    defaultOption?: boolean;     // Capture positional args
}

ParseOptions

interface ParseOptions {
    partial?: boolean;           // Preserve unknown options
    stopAtFirstUnknown?: boolean; // Stop at unknown option
    camelCase?: boolean;         // Convert to camelCase
    argv?: string[];             // Custom argv array
}

Examples

Basic:

parseArgs([{ name: "file", type: String }]);

With alias:

parseArgs([{ name: "verbose", alias: "v", type: Boolean }]);

Multiple values:

parseArgs([{ name: "include", type: String, multiple: true }]);

Default value:

parseArgs([{ name: "port", type: Number, defaultValue: 3000 }]);

Positional:

parseArgs([{ name: "files", type: String, multiple: true, defaultOption: true }]);
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