# sb-command

> CLI command and options parser

Latest version **2.0.6** (published 2017-03-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install sb-command
pnpm add sb-command
yarn add sb-command
bun add sb-command
```

## 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.0.6 |
| Published | 2017-03-03 |
| First published | 2016-12-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | steelbrain |
| Maintainers | steelbrain |
| Keywords | cli, command, app |

## Links

- npm: https://www.npmjs.com/package/sb-command
- Repository: https://github.com/steelbrain/command
- Homepage: https://github.com/steelbrain/command#readme
- Issues: https://github.com/steelbrain/command/issues
- npm.io page: https://npm.io/package/sb-command

## Dependencies (2)

- [cliff](https://npm.io/package/cliff.md) ^0.1.10
- [camelcase](https://npm.io/package/camelcase.md) ^4.0.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

- 2.0.6 (latest) — 2017-03-03
- 2.0.5 — 2017-02-23
- 2.0.4 — 2017-02-23
- 2.0.3 — 2017-02-23
- 2.0.2 — 2017-02-21
- 2.0.1 — 2017-02-20
- 2.0.0 — 2017-02-20
- 1.0.0 — 2016-12-15
- 0.0.1 — 2016-12-15

## README

sb-command
=========

sb-command is the CLI parser you'll ever need.

## Documentation

There are several types of parameters

 - `[name]` means `name` is an optional parameter
 - `<name>` means `name` is a required parameter
 - `[name...]` means `name` is an optional variadic parameter
 - `<name...>` means `name` is a required variadic parameter
 - Specifying no parameter with an option means it's boolean

To add nested commands, simply join them with dot. For example for `remote add` use `remote.add` as the command name.

To add configs specific to certain commands, do the `.option()` call after *that* particular `.command()` call. If you want your configs to be global, add them before adding any other command.

### Example

```js
const command = require('sb-command')

command
  .version('0.0.1')
  .description('Git Versonal Control System')
  .option('--disable-cache', 'Disable Git Cache')
  .command('init', 'Initialize an empty repo', function(options) {
    console.log('git-init')
  })
  .option('--shallow-copy', 'Initialize with shallow copy')
  .command('add [file]', 'Add file contents to index', function(options, file) {
    console.log('git-add', files)
  })
  .option('--dry-run', 'Try to stage the file into git index but dont actually do it')
  .default(function(options, parameters) {
    console.log(options, parameters)
  })
  .process()

```

### API

```js
export class Command {
  default(callback: Function): this
  version(version: string): this
  description(descriptionText: string): this
  command(commandName: string, description: string, callback: ?Function): this
  option(option: string, description: string, defaultValue: any = null): this
  process(argv: Array<string> = process.argv): Promise<any>
  showHelp(): string
}
export default new command
```

## LICENSE

This package is licensed under the terms of MIT License. See the LICENSE file for more info.

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