power-options
TypeScript icon, indicating that this package has built-in type declarations

0.3.4 • Public • Published

power-options

CLI Option parser for NodeJS

This library contains an advanced CLI option parser for NodeJS console applications.

Installing

For the latest version:

npm install power-options

Usage

// Importing (TypeScript)
import { parseCommandLine } from "power-options";
 
// Importing (JavaScript - CommonJS)
const parseCommandLine = require("power-options").parseCommandLine;
 
// Usage
const { options, help, error, status, group } = parseCommandLine(process.argv.slice(2), {
    options: {
        "help": { shortName: "h", alias: ["?"], help: true },
        "version": { shortName: "v" },
    }
});
 
if (error) {
    console.error(error);
    if (help) {
        // print help
    }
    process.exit(status);
}
else if (help) {
    // print help
    process.exit(0);
}
else {
    // use options/group
}

Dependencies (2)

Dev Dependencies (19)

Package Sidebar

Install

npm i power-options

Weekly Downloads

1,299

Version

0.3.4

License

Apache-2.0

Unpacked Size

246 kB

Total Files

42

Last publish

Collaborators

  • rbuckton