# @oclif/command

> oclif base command

Latest version **1.8.36** (published 2023-08-19) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @oclif/command
pnpm add @oclif/command
yarn add @oclif/command
bun add @oclif/command
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.8.36 |
| Published | 2023-08-19 |
| First published | 2018-02-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=12.0.0 |
| Dependencies | 6 |
| Unpacked size | 22.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 136 |
| Author | Salesforce |
| Maintainers | anycli-bot, rodesp, mdonnalley, rasphilco, dickeyxxx, amphro, chadian, salesforce-releases |
| Keywords | oclif |

## Links

- npm: https://www.npmjs.com/package/@oclif/command
- Repository: https://github.com/oclif/command
- Issues: https://github.com/oclif/command/issues
- npm.io page: https://npm.io/package/@oclif/command

## Dependencies (6)

- [debug](https://npm.io/package/debug.md) ^4.1.1
- [semver](https://npm.io/package/semver.md) ^7.5.4
- [@oclif/help](https://npm.io/package/@oclif/help.md) ^1.0.1
- [@oclif/config](https://npm.io/package/@oclif/config.md) ^1.18.2
- [@oclif/errors](https://npm.io/package/@oclif/errors.md) ^1.3.6
- [@oclif/parser](https://npm.io/package/@oclif/parser.md) ^3.8.17

## 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

- 1.8.36 (latest) — 2023-08-19
- 1.6.0-rc1.2 (help-beta) — 2020-04-22
- 1.8.35 — 2023-07-29
- 1.8.34 — 2023-07-22
- 1.8.33 — 2023-07-19
- 1.8.32 — 2023-07-15
- 1.8.31 — 2023-07-08
- 1.8.30 — 2023-07-01
- 1.8.29 — 2023-06-24
- 1.8.28 — 2023-06-17
- 1.8.27 — 2023-06-03
- 1.8.26 — 2023-05-20
- 1.8.25 — 2023-05-13
- 1.8.24 — 2023-04-22
- 1.8.23 — 2023-04-15
- … 94 more at https://npm.io/package/@oclif/command/versions

## README

@oclif/command
===============

**This library been replaced by [@oclif/core](https://github.com/oclif/core) and is now in maintenance mode. We will only consider PRs that address security concerns.**

oclif base command

[![Version](https://img.shields.io/npm/v/@oclif/command.svg)](https://npmjs.org/package/@oclif/command)
[![CircleCI](https://circleci.com/gh/oclif/command/tree/main.svg?style=shield)](https://circleci.com/gh/oclif/command/tree/main)
[![Appveyor CI](https://ci.appveyor.com/api/projects/status/github/oclif/command?branch=main&svg=true)](https://ci.appveyor.com/project/heroku/command/branch/main)
[![Known Vulnerabilities](https://snyk.io/test/npm/@oclif/command/badge.svg)](https://snyk.io/test/npm/@oclif/command)
[![Downloads/week](https://img.shields.io/npm/dw/@oclif/command.svg)](https://npmjs.org/package/@oclif/command)
[![License](https://img.shields.io/npm/l/@oclif/command.svg)](https://github.com/oclif/command/blob/main/package.json)

This is about half of the main codebase for oclif. The other half lives in [@oclif/config](https://github.com/oclif/config). This can be used directly, but it probably makes more sense to build your CLI with the [generator](https://github.com/oclif/oclif).

Usage
=====

Without the generator, you can create a simple CLI like this:

**TypeScript**
```js
#!/usr/bin/env ts-node

import * as fs from 'fs'
import {Command, flags} from '@oclif/command'

class LS extends Command {
  static flags = {
    version: flags.version(),
    help: flags.help(),
    // run with --dir= or -d=
    dir: flags.string({
      char: 'd',
      default: process.cwd(),
    }),
  }

  async run() {
    const {flags} = this.parse(LS)
    let files = fs.readdirSync(flags.dir)
    for (let f of files) {
      this.log(f)
    }
  }
}

LS.run()
.catch(require('@oclif/errors/handle'))
```

**JavaScript**
```js
#!/usr/bin/env node

const fs = require('fs')
const {Command, flags} = require('@oclif/command')

class LS extends Command {
  async run() {
    const {flags} = this.parse(LS)
    let files = fs.readdirSync(flags.dir)
    for (let f of files) {
      this.log(f)
    }
  }
}

LS.flags = {
  version: flags.version(),
  help: flags.help(),
  // run with --dir= or -d=
  dir: flags.string({
    char: 'd',
    default: process.cwd(),
  }),
}

LS.run()
.catch(require('@oclif/errors/handle'))
```

Then run either of these with:

```sh-session
$ ./myscript
...files in current dir...
$ ./myscript --dir foobar
...files in ./foobar...
$ ./myscript --version
myscript/0.0.0 darwin-x64 node-v9.5.0
$ ./myscript --help
USAGE
  $ @oclif/command

OPTIONS
  -d, --dir=dir  [default: /Users/jdickey/src/github.com/oclif/command]
  --help         show CLI help
  --version      show CLI version
```

See the [generator](https://github.com/oclif/oclif) for all the options you can pass to the command.

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