# commander-extras

> Extra functionality for commander including environment variables and notes

Latest version **1.4.0** (published 2022-11-24) · MIT license · 0 weekly downloads

## Install

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

## 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 | 1.4.0 |
| Published | 2022-11-24 |
| First published | 2019-04-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Matt Carter |
| Maintainers | hash-bang |
| Keywords | commander |

## Links

- npm: https://www.npmjs.com/package/commander-extras
- Repository: https://github.com/hash-bang/commander-extras
- Homepage: https://github.com/hash-bang/commander-extras#readme
- Issues: https://github.com/hash-bang/commander-extras/issues
- npm.io page: https://npm.io/package/commander-extras

## Recent versions

- 1.4.0 (latest) — 2022-11-24
- 1.3.1 — 2022-09-20
- 1.3.0 — 2022-07-18
- 1.2.0 — 2022-07-18
- 1.1.6 — 2021-05-24
- 1.1.5 — 2021-03-11
- 1.1.4 — 2021-03-02
- 1.1.3 — 2020-09-17
- 1.1.2 — 2020-06-29
- 1.1.1 — 2020-05-14
- 1.1.0 — 2019-08-30
- 1.0.1 — 2019-04-17
- 1.0.0 — 2019-04-17

## README

Commander-Extras
================
Extremely small utility which adds additional functionality to the [Commander](https://github.com/tj/commander.js) NPM module.


```javascript
// Using the global prototype mutate method
var commander = require('commander');
require('commander-extras');

var program = commander.option('-v, --verbose', 'Be verbose')
	.env('FOO', 'FOO Environment variable desription')
	.env('BAR', 'BAR Environment variable desription')
	.env('BAZ', 'FOO environment variable desription')
	.note('Note one')
	.note('Note two')
	.note('Note three')
	.parse(process.argv)
	.opts()
```

```javascript
// Using the global prototype mutate method
var Commander = require('commander');
var commanderExtras = require('commander-extras');

var command = new Commander.Command();
var commander = commanderExtras(command); // Mutate only our custom command

var program = commander.option('-v, --verbose', 'Be verbose')
	.env('FOO', 'FOO Environment variable desription')
	.env('BAR', 'BAR Environment variable desription')
	.env('BAZ', 'FOO environment variable desription')
	.note('Note one')
	.note('Note two')
	.note('Note three')
	.parse(process.argv)
	.opts()
```


API
===
The following API's are added to the existing Commander prototype:

CommanderExtras(Command?)
-------------------------
Take an optional `Commander.Command` instance and add the custom methods to it.


env(name, description)
----------------------
Used to define an environment variable.


example(cli, title)
----------------------
Used to define an example with an optional title.


extend(function)
----------------
Run a function with the current commander context to extend it.
This is useful to extend sub-commands with common settings.
The function is called as `(commanderContext)` and has the same as its context.



note(description)
-----------------
Add an additional note to display at the bottom of the help output.

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