# commander-ts

> TypeScript decorators that enhance commander

Latest version **0.2.0** (published 2021-10-20) · ISC license · 0 weekly downloads

## Install

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

## Health

**Score 35/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

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

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2021-10-20 |
| First published | 2018-04-20 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 43 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 18 |
| Author | Matt Strom |
| Maintainers | matt-strom |
| Keywords | command line, cli, commander, typescript |

## Links

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

## Dependencies (1)

- [commander](https://npm.io/package/commander.md) ^7.2.0

## 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.2.0 (latest) — 2021-10-20
- 0.1.5 — 2018-07-21
- 0.1.4 — 2018-05-15
- 0.1.3 — 2018-05-15
- 0.1.2 — 2018-04-25
- 0.1.1 — 2018-04-20
- 0.1.0 — 2018-04-20

## README

commander-ts
================================

TypeScript decorators for [commander](https://github.com/tj/commander.js/) that makes developing command line tools with Node even easier.

## Usage
1. Import `commander-ts` into your project.
	```
	$ npm install --save commander-ts
	```

## Example
_index.ts_
```
import {
	action, command, commandOption, description, option,
	optionalArg, program, requiredArg, usage,
	variadicArg, version,
	Command
} from 'commander-ts';

@program()
@version('1.0.0')
@description('A basic program')
@usage('--help')
export class Program {
	@option('--env <env>')
	env: string = null;

	constructor() {}

	run(@requiredArg('message') message) {
		console.log(`Message: ${message}`);
	}

	@command()
	@commandOption('--reverse')
	print(
		this: Command,
		@requiredArg('first') first,
		@optionalArg('last') last,
		@variadicArg('credentials') credentials
	) {
		if (this.reverse) {
			console.log(`Name: ${last}, ${first}, ${credentials.join(', ')}`);
		} else {
			console.log(`Name: ${first} ${last}, ${credentials.join(', ')}`);
		}
	}
}

const p = new Program();

```

```
$ node index.js "Hello world"
  Hello world

$ node index.js print Jack Bauer
  Jack Bauer

$ node index.js print James Bond --reverse
  Bond, James

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