# trujs-cmdargs

> A simple module for parsing command line arguments in NodeJS

Latest version **0.0.3** (published 2018-01-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install trujs-cmdargs
pnpm add trujs-cmdargs
yarn add trujs-cmdargs
bun add trujs-cmdargs
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2018-01-07 |
| First published | 2017-10-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Rodger McIntosh |
| Maintainers | rmcintosh |
| Keywords | command, line, arguments |

## Links

- npm: https://www.npmjs.com/package/trujs-cmdargs
- Repository: https://github.com/trujs/TruJS.cmdArgs
- Homepage: https://github.com/trujs/TruJS.cmdArgs#readme
- Issues: https://github.com/trujs/TruJS.cmdArgs/issues
- npm.io page: https://npm.io/package/trujs-cmdargs

## Alternatives

- [@salesforce/cli](https://npm.io/package/@salesforce/cli.md) — 389.7K weekly downloads
- [@mintlify/cli](https://npm.io/package/@mintlify/cli.md) — 208.9K weekly downloads
- [@grafana/e2e-selectors](https://npm.io/package/@grafana/e2e-selectors.md) — 128.7K weekly downloads
- [mintlify](https://npm.io/package/mintlify.md) — 112.0K weekly downloads
- [@intlayer/cli](https://npm.io/package/@intlayer/cli.md) — 22.8K weekly downloads

## Recent versions

- 0.0.3 (latest) — 2018-01-07
- 0.0.2 — 2018-01-07
- 0.0.1 — 2017-10-17

## README

# TruJS.cmdArgs

A simple module for parsing command line arguments in NodeJS.

This module returns a simple worker function that takes an argv array and returns a ``CmdArgs`` object, representing the arguments.

###### Usage

```javascript
var cmdArgs = require("trujs-cmdargs")(process.argv);
```

###### Command Line Parts
```
node cli.js listen --config secure,port:3000 -fvt --serve -g
```
|node|script|command|named-option|flag array|named-option|flag|
|----|------|-------|------------|----------|------------|----|
|node|cli.js|listen|--config secure,port:3000|-fvt|--serve|-g|

* **command**: The first argument after the script path, before any named-options or flags.
* **named-option**: Any argument that is prefixed with a double dash ("--"); can be followed by an array of value and/or name:value members.
* **flag array**: Any argument that is prefixed with a single dash ("-"); each character is an individual flag.

###### Example

```
node cli.js listen --config secure,port:3000 -fvt --serve
```

* `listen`: The Command
* `--config`: A *named-option* with the value `secure,port:3000`
* `-fvt`: Flags f, v, and t
* `--serve`: A *named-option* without a value

```json
{
    "_executable": "node"
    , "_script": "cli.js"
    , "command": "listen"
    , "oridnals": ["config","serve"]
    , "flags": ["f","v","t"]
    , "config": [
        "secure"
        , {
            "name": "port"
            , "value": "3000"
        }
    ]
    , "serve": null
}
```
###### Static Members
| Member    |Description|
|-----------|-----------|
|_executable|Always ``node`` (``argv[0]``).
|_script    |The path to the JavaScript file, i.e. the argument following <br>`node` in the command line (``argv[1]``).
|command    |The first option following the path as long as it's<br>not a *named-option* or flag (Default null).
|flags      |An array of flags, in the order they appeared in (Default<br>empty array)
|ordinals   |An array of *named-option names*, in the order they appeared<br>in the command line arguments.

---
_Source: https://npm.io/package/trujs-cmdargs · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
