# safe-commander

> the complete solution for node.js command-line programs

Latest version **2.11.2** (published 2018-02-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install safe-commander
pnpm add safe-commander
yarn add safe-commander
bun add safe-commander
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.11.2 |
| Published | 2018-02-28 |
| First published | 2017-06-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.6.x |
| Dependencies | 1 |
| Unpacked size | 6.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | bySabi Files |
| Maintainers | bysabi |
| Keywords | safe, safe-commander, commander, command, option, parser |

## Links

- npm: https://www.npmjs.com/package/safe-commander
- Repository: https://github.com/bySabi/safe-commander.js
- Homepage: https://github.com/bySabi/safe-commander.js#readme
- Issues: https://github.com/bySabi/safe-commander.js/issues
- npm.io page: https://npm.io/package/safe-commander

## Dependencies (1)

- [commander](https://npm.io/package/commander.md) ~2.11.0

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 2.11.2 (latest) — 2018-02-28
- 2.11.1 — 2017-07-13
- 2.11.0 — 2017-07-13
- 2.10.4 — 2017-06-26
- 2.10.3 — 2017-06-26
- 2.10.2 — 2017-06-26
- 2.10.1 — 2017-06-26
- 2.10.0 — 2017-06-26

## README

# safe Commander.js

[![npm version](https://badge.fury.io/js/safe-commander.svg)](https://badge.fury.io/js/safe-commander)
[![npm downloads](https://img.shields.io/npm/dm/safe-commander.svg?style=flat-square)](https://www.npmjs.com/package/safe-commander)

[Commander.js](https://github.com/tj/commander.js/) has a major design flaw in the `option` API, such that options like `name`, `opts`, `command`, `option`, `domain` collide with names of properties on the commander instance. See issues: [#404](https://github.com/tj/commander.js/issues/404), [#584](https://github.com/tj/commander.js/issues/584), [#648](https://github.com/tj/commander.js/issues/648)

**Important:** `safe-commander` solves the name collision problem, however using it requires **[changing your code](#breaking-changes)**.

## Installation
    $ npm install safe-commander --save

## Usage
Follow Commander [API documentation](http://tj.github.com/commander.js/)

## Breaking changes
Options created with `option` API will no longer be available on the Commander instance object.  Instead, a new object store `optsObj` was added.

The original [Commander.js](https://github.com/tj/commander.js/#option-parsing) example should be modified as follows:

```diff
 #!/usr/bin/env node

 /**
  * Module dependencies.
  */

-var program = require('commander');
+var program = require('safe-commander');

 program
   .version('0.1.0')
   .option('-p, --peppers', 'Add peppers')
   .option('-P, --pineapple', 'Add pineapple')
   .option('-b, --bbq-sauce', 'Add bbq sauce')
   .option('-c, --cheese [type]', 'Add the specified type of cheese [marble]', 'marble')
   .parse(process.argv);

 console.log('you ordered a pizza with:');
-if (program.peppers) console.log('  - peppers');
-if (program.pineapple) console.log('  - pineapple');
-if (program.bbqSauce) console.log('  - bbq');
-console.log('  - %s cheese', program.cheese);
+if (program.optsObj.peppers) console.log('  - peppers');
+if (program.optsObj.pineapple) console.log('  - pineapple');
+if (program.optsObj.bbqSauce) console.log('  - bbq');
+console.log('  - %s cheese', program.optsObj.cheese);
```

## Credits

### author
* [@bySabi](https://github.com/bySabi)

### contributors
* Ildar Sagdejev <> [@specious](https://github.com/specious)


## Contributing

* Improve the documentation
* Feel free to open any PR

## License

[MIT][mit-license]

[mit-license]:./LICENSE

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