@oclif/core
base library for oclif CLIs
Last updated 2 years ago by salesforce-releases .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install @oclif/core 
SYNC missed versions from official npm registry.

oclif: Node.JS Open CLI Framework

Version Downloads/week License

🗒 Description

This is a framework for building CLIs in Node.js. This framework was built out of the Salesforce CLI but generalized to build any custom CLI. It's designed both for single-file CLIs with a few flag options (like cat or ls), or for very complex CLIs that have subcommands (like git or heroku).

See the docs for more information.

🚀 Getting Started Tutorial

The Getting Started tutorial is a step-by-step guide to introduce you to oclif. If you have not developed anything in a command line before, this tutorial is a great place to get started.

✨ Features

  • Flag/Argument parsing - No CLI framework would be complete without a flag parser. We've built a custom one from years of experimentation that we feel consistently handles user input flexible enough for the user to be able to use the CLI in ways they expect, but without compromising strictness guarantees to the developer.
  • Super Speed - The overhead for running an oclif CLI command is almost nothing. It requires very few dependencies (only 28 dependencies in a minimal setup—including all transitive dependencies). Also, only the command to be executed will be required with node. So large CLIs with many commands will load equally as fast as a small one with a single command.
  • CLI Generator - Run a single command to scaffold out a fully functional CLI and get started quickly. See Getting Started Tutorial.
  • Testing Helpers - We've put a lot of work into making commands easier to test and mock out stdout/stderr. The generator will automatically create scaffolded tests.
  • Auto-documentation - By default you can pass --help to the CLI to get help such as flag options and argument information. This information is also automatically placed in the README whenever the npm package of the CLI is published. See the hello-world CLI example
  • Plugins - Using plugins, users of the CLI can extend it with new functionality, a CLI can be split into modular components, and functionality can be shared amongst multiple CLIs. See Building your own plugin.
  • Hooks - Use lifecycle hooks to run functionality any time a CLI starts, or on custom triggers. Use this whenever custom functionality needs to be shared between various components of the CLI.
  • TypeScript - Everything in the core of oclif is written in TypeScript and the generator will build fully configured TypeScript CLIs. If you use plugins support, the CLI will automatically use ts-node to run the plugins enabling you to use TypeScript with minimal-to-no boilerplate needed for any oclif CLI.
  • Auto-updating Installers - oclif can package your CLI into different installers that will not require the user to already have node installed on the machine. These can be made auto-updatable by using plugin-update.
  • Everything is Customizable - Pretty much anything can be swapped out and replaced inside oclif if needed—including the arg/flag parser.
  • Autocomplete - Automatically include autocomplete for your CLI. This includes not only command names and flag names, but flag values as well. For example, it's possible to configure the Heroku CLI to have completions for Heroku app names:
$ heroku info --app=<tab><tab> # will complete with all the Heroku apps a user has in their account

📌 Requirements

Currently, Node 18+ is supported. We support the LTS versions of Node. You can add the node package to your CLI to ensure users are running a specific version of Node.

📌 Migrating

See the v3 migration guide for an overview of breaking changes that occurred between v2 and v3.

See the v2 migration guide for an overview of breaking changes that occurred between v1 and v2.

Migrating from @oclif/config and @oclif/command? See the v1 migration guide.

📌 Documentation

The official oclif website, oclif.io, contains all the documentation you need for developing a CLI with oclif.

If there's anything you'd like to see in the documentation, please submit an issue on the oclif.github.io repo.

🚀 Standalone Usage

We strongly encourage you generate an oclif CLI using the oclif cli. The generator will generate an npm package with @oclif/core as a dependency.

You can, however, use @oclif/core in a standalone script like this:

#!/usr/bin/env -S node --loader ts-node/esm --no-warnings=ExperimentalWarning

import * as fs from 'fs'
import {Command, Flags, flush, handle} from '@oclif/core'

class LS extends Command {
  static description = 'List the files in a directory.'
  static flags = {
    version: Flags.version(),
    help: Flags.help(),
    dir: Flags.string({
      char: 'd',
      default: process.cwd(),
    }),
  }

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

LS.run().then(
  async () => {
    await flush()
  },
  async (err) => {
    await handle(err)
  },
)

Then run it like this:

$ ts-node myscript.ts
...files in current dir...

🚀 Contributing

See the contributing guide.

Current Tags

  • 4.0.0-beta.17                                ...           beta (5 months ago)
  • 3.20.1-dev.1                                ...           dev (8 months ago)
  • 4.0.30                                ...           latest (24 days ago)
  • 2.16.0                                ...           previous (7 months ago)
  • 3.19.2-qa.0                                ...           qa (9 months ago)

404 Versions

  • 4.0.30                                ...           24 days ago
  • 4.0.29                                ...           a month ago
  • 4.0.28                                ...           a month ago
  • 4.0.27                                ...           a month ago
  • 4.0.26                                ...           a month ago
  • 4.0.25                                ...           a month ago
  • 4.0.24                                ...           a month ago
  • 4.0.23                                ...           2 months ago
  • 4.0.22                                ...           2 months ago
  • 4.0.21                                ...           2 months ago
  • 4.0.20                                ...           2 months ago
  • 4.0.19                                ...           3 months ago
  • 4.0.18                                ...           3 months ago
  • 4.0.17                                ...           4 months ago
  • 4.0.16                                ...           4 months ago
  • 4.0.15                                ...           4 months ago
  • 4.0.14                                ...           4 months ago
  • 4.0.13                                ...           4 months ago
  • 4.0.12                                ...           4 months ago
  • 4.0.11                                ...           4 months ago
  • 4.0.10                                ...           4 months ago
  • 4.0.9                                ...           4 months ago
  • 4.0.8                                ...           4 months ago
  • 4.0.7                                ...           5 months ago
  • 4.0.6                                ...           5 months ago
  • 4.0.5                                ...           5 months ago
  • 4.0.4                                ...           5 months ago
  • 4.0.3                                ...           5 months ago
  • 4.0.2                                ...           5 months ago
  • 4.0.1                                ...           5 months ago
  • 4.0.0                                ...           5 months ago
  • 4.0.0-beta.17                                ...           5 months ago
  • 4.0.0-beta.16                                ...           5 months ago
  • 3.27.0                                ...           5 months ago
  • 3.26.9                                ...           5 months ago
  • 4.0.0-beta.15                                ...           5 months ago
  • 4.0.0-beta.14                                ...           5 months ago
  • 3.26.8                                ...           5 months ago
  • 3.26.7                                ...           5 months ago
  • 4.0.0-beta.13                                ...           6 months ago
  • 4.0.0-beta.12                                ...           6 months ago
  • 4.0.0-beta.11                                ...           6 months ago
  • 4.0.0-beta.10                                ...           6 months ago
  • 4.0.0-beta.9                                ...           6 months ago
  • 4.0.0-beta.8                                ...           6 months ago
  • 4.0.0-beta.7                                ...           6 months ago
  • 4.0.0-beta.6                                ...           6 months ago
  • 3.26.6                                ...           6 months ago
  • 4.0.0-beta.5                                ...           6 months ago
  • 3.26.5                                ...           6 months ago
  • 4.0.0-beta.4                                ...           7 months ago
  • 4.0.0-beta.3                                ...           7 months ago
  • 4.0.0-beta.2                                ...           7 months ago
  • 3.26.4                                ...           7 months ago
  • 4.0.0-beta.1                                ...           7 months ago
  • 3.26.3                                ...           7 months ago
  • 3.26.2                                ...           7 months ago
  • 2.16.0                                ...           7 months ago
  • 3.26.1                                ...           7 months ago
  • 3.26.0                                ...           8 months ago
  • 3.25.3                                ...           8 months ago
  • 3.25.2                                ...           8 months ago
  • 3.25.1                                ...           8 months ago
  • 3.25.0                                ...           8 months ago
  • 3.24.0                                ...           8 months ago
  • 3.23.1                                ...           8 months ago
  • 3.23.0                                ...           8 months ago
  • 3.22.0                                ...           8 months ago
  • 3.21.2                                ...           8 months ago
  • 3.21.1                                ...           8 months ago
  • 3.21.0                                ...           8 months ago
  • 3.20.1-dev.1                                ...           8 months ago
  • 3.20.1-dev.0                                ...           9 months ago
  • 3.20.0                                ...           9 months ago
  • 3.19.7                                ...           9 months ago
  • 3.19.6                                ...           9 months ago
  • 3.19.5                                ...           9 months ago
  • 3.19.5-dev.0                                ...           9 months ago
  • 3.19.4                                ...           9 months ago
  • 3.19.3                                ...           9 months ago
  • 3.19.3-dev.0                                ...           9 months ago
  • 3.19.2-dev.0                                ...           9 months ago
  • 3.19.2-qa.0                                ...           9 months ago
  • 3.19.2                                ...           9 months ago
  • 3.19.1                                ...           9 months ago
  • 3.19.0                                ...           9 months ago
  • 3.18.2                                ...           9 months ago
  • 3.18.1                                ...           10 months ago
  • 3.18.0                                ...           10 months ago
  • 3.17.0                                ...           10 months ago
  • 3.16.0                                ...           10 months ago
  • 3.15.1                                ...           a year ago
  • 3.15.0                                ...           a year ago
  • 3.14.1                                ...           a year ago
  • 3.14.0                                ...           a year ago
  • 3.13.2                                ...           a year ago
  • 3.13.1                                ...           a year ago
  • 3.13.0                                ...           a year ago
  • 3.12.1                                ...           a year ago
  • 3.12.0                                ...           a year ago
  • 3.11.1-dev.1                                ...           a year ago
  • 3.11.1-dev.0                                ...           a year ago
  • 3.11.0                                ...           a year ago
  • 3.10.8                                ...           a year ago
  • 3.10.7                                ...           a year ago
  • 3.10.6                                ...           a year ago
  • 3.10.5                                ...           a year ago
  • 3.10.4                                ...           a year ago
  • 3.10.3                                ...           a year ago
  • 3.10.2                                ...           a year ago
  • 3.10.1                                ...           a year ago
  • 3.10.0                                ...           a year ago
  • 3.9.2                                ...           a year ago
  • 3.9.1                                ...           a year ago
  • 3.9.0                                ...           a year ago
  • 3.8.0                                ...           a year ago
  • 3.7.1                                ...           a year ago
  • 3.7.0                                ...           a year ago
  • 3.6.0                                ...           a year ago
  • 3.4.1-dev.0                                ...           a year ago
  • 3.5.0                                ...           a year ago
  • 3.4.0                                ...           a year ago
  • 3.3.3                                ...           a year ago
  • 3.3.3-dev.0                                ...           a year ago
  • 3.3.2                                ...           a year ago
  • 3.3.1                                ...           a year ago
  • 3.3.0                                ...           a year ago
  • 3.2.1                                ...           a year ago
  • 3.2.0                                ...           a year ago
  • 3.1.0                                ...           a year ago
  • 3.0.9                                ...           a year ago
  • 3.0.8                                ...           a year ago
  • 3.0.7                                ...           a year ago
  • 3.0.6                                ...           a year ago
  • 3.0.5                                ...           a year ago
  • 3.0.5-dev.0                                ...           a year ago
  • 3.0.4                                ...           a year ago
  • 3.0.3                                ...           a year ago
  • 3.0.2                                ...           a year ago
  • 3.0.1                                ...           a year ago
  • 3.0.0                                ...           a year ago
  • 3.0.0-beta.25                                ...           a year ago
  • 3.0.0-beta.24                                ...           a year ago
  • 3.0.0-beta.23                                ...           a year ago
  • 3.0.0-beta.22                                ...           a year ago
  • 3.0.0-beta.21                                ...           a year ago
  • 3.0.0-beta.20                                ...           a year ago
  • 3.0.0-beta.19                                ...           a year ago
  • 3.0.0-beta.18                                ...           a year ago
  • 3.0.0-beta.17                                ...           a year ago
  • 3.0.0-beta.16                                ...           a year ago
  • 3.0.0-beta.15                                ...           a year ago
  • 3.0.0-beta.14                                ...           a year ago
  • 3.0.0-beta.13                                ...           a year ago
  • 3.0.0-beta.12                                ...           a year ago
  • 2.15.0                                ...           a year ago
  • 3.0.0-beta.11                                ...           a year ago
  • 3.0.0-beta.10                                ...           a year ago
  • 3.0.0-beta.9                                ...           a year ago
  • 3.0.0-beta.8                                ...           a year ago
  • 3.0.0-beta.7                                ...           a year ago
  • 3.0.0-beta.6                                ...           a year ago
  • 3.0.0-beta.5                                ...           a year ago
  • 3.0.0-beta.4                                ...           a year ago
  • 3.0.0-beta.3                                ...           a year ago
  • 3.0.0-beta.2                                ...           a year ago
  • 2.14.0                                ...           a year ago
  • 2.13.0                                ...           a year ago
  • 2.12.0                                ...           a year ago
  • 2.11.11                                ...           a year ago
  • 2.11.10                                ...           a year ago
  • 2.11.9                                ...           a year ago
  • 3.0.0-beta.1                                ...           a year ago
  • 2.11.8                                ...           a year ago
  • 2.11.7                                ...           a year ago
  • 2.11.6                                ...           a year ago
  • 2.11.5                                ...           a year ago
  • 2.11.4                                ...           a year ago
  • 2.11.3                                ...           a year ago
  • 2.11.2                                ...           a year ago
  • 2.11.1                                ...           a year ago
  • 2.11.0                                ...           a year ago
  • 2.10.1                                ...           a year ago
  • 2.10.0                                ...           a year ago
  • 2.9.5                                ...           a year ago
  • 2.9.4                                ...           a year ago
  • 2.9.3                                ...           a year ago
  • 2.9.2                                ...           a year ago
  • 2.9.1                                ...           a year ago
  • 2.9.0                                ...           a year ago
  • 2.8.12                                ...           a year ago
  • 2.8.11                                ...           a year ago
  • 2.8.10                                ...           a year ago
  • 2.8.8                                ...           a year ago
  • 2.8.7                                ...           a year ago
  • 2.8.6                                ...           a year ago
  • 2.8.5                                ...           2 years ago
  • 2.8.4                                ...           2 years ago
  • 2.8.3                                ...           2 years ago
  • 2.8.3-beta.1                                ...           2 years ago
  • 2.8.2                                ...           2 years ago
  • 2.8.1                                ...           2 years ago
  • 2.8.1-beta.4                                ...           2 years ago
  • 2.8.1-beta.1                                ...           2 years ago
  • 2.8.0                                ...           2 years ago
  • 2.7.2-beta.1                                ...           2 years ago
  • 2.7.1                                ...           2 years ago
  • 2.7.0                                ...           2 years ago
  • 2.6.5                                ...           2 years ago
  • 2.6.4                                ...           2 years ago
  • 2.6.3                                ...           2 years ago
  • 2.6.2                                ...           2 years ago
  • 2.6.1                                ...           2 years ago
  • 2.6.0                                ...           2 years ago
  • 2.5.2                                ...           2 years ago
  • 2.5.1                                ...           2 years ago
  • 2.5.0                                ...           2 years ago
  • 2.4.0                                ...           2 years ago
  • 2.3.2                                ...           2 years ago
  • 2.3.1                                ...           2 years ago
  • 2.3.0                                ...           2 years ago
  • 2.2.1                                ...           2 years ago
  • 2.2.0                                ...           2 years ago
  • 2.1.7                                ...           2 years ago
  • 2.1.6                                ...           2 years ago
  • 2.1.5                                ...           2 years ago
  • 1.26.2                                ...           2 years ago
  • 2.1.4                                ...           2 years ago
  • 2.1.3                                ...           2 years ago
  • 2.1.2                                ...           2 years ago
  • 2.1.1                                ...           2 years ago
  • 2.1.0                                ...           2 years ago
  • 2.0.11                                ...           2 years ago
  • 2.0.10                                ...           2 years ago
  • 2.0.9                                ...           2 years ago
  • 2.0.8                                ...           2 years ago
  • 2.0.7                                ...           2 years ago
  • 2.0.6                                ...           2 years ago
  • 2.0.5                                ...           2 years ago
  • 2.0.4                                ...           2 years ago
  • 1.26.1                                ...           2 years ago
  • 1.24.4                                ...           2 years ago
  • 2.0.3                                ...           2 years ago
  • 2.0.2-beta.11                                ...           2 years ago
  • 1.26.0                                ...           2 years ago
  • 2.0.2-beta.10                                ...           2 years ago
  • 1.25.0                                ...           2 years ago
  • 2.0.2-beta.9                                ...           2 years ago
  • 2.0.2-beta.8                                ...           2 years ago
  • 1.24.3                                ...           2 years ago
  • 2.0.2-beta.7                                ...           2 years ago
  • 1.24.2                                ...           2 years ago
  • 1.24.1                                ...           2 years ago
  • 2.0.2-beta.6                                ...           2 years ago
  • 2.0.2-beta.5                                ...           2 years ago
  • 2.0.2-beta.4                                ...           2 years ago
  • 2.0.2-beta.2                                ...           2 years ago
  • 2.0.2-beta.1                                ...           2 years ago
  • 2.0.0-beta.7                                ...           2 years ago
  • 2.0.0-beta.6                                ...           2 years ago
  • 2.0.0-beta.5                                ...           2 years ago
  • 2.0.0-beta.4                                ...           2 years ago
  • 2.0.0-beta.3                                ...           2 years ago
  • 2.0.1                                ...           2 years ago
  • 1.24.0                                ...           2 years ago
  • 1.23.2                                ...           2 years ago
  • 1.23.1                                ...           2 years ago
  • 1.23.0                                ...           2 years ago
  • 1.22.0                                ...           2 years ago
  • 1.21.0                                ...           2 years ago
  • 1.20.4                                ...           2 years ago
  • 1.20.3                                ...           2 years ago
  • 1.20.2                                ...           2 years ago
  • 1.20.1                                ...           2 years ago
  • 1.20.0                                ...           2 years ago
  • 1.19.2                                ...           2 years ago
  • 1.19.1                                ...           2 years ago
  • 1.19.0                                ...           2 years ago
  • 1.18.0                                ...           2 years ago
  • 1.17.0                                ...           2 years ago
  • 1.16.7                                ...           2 years ago
  • 1.16.6                                ...           2 years ago
  • 1.16.5                                ...           2 years ago
  • 1.16.4                                ...           2 years ago
  • 1.16.3                                ...           2 years ago
  • 1.16.2                                ...           2 years ago
  • 1.16.1                                ...           2 years ago
  • 1.16.0                                ...           2 years ago
  • 1.15.0                                ...           2 years ago
  • 1.14.2                                ...           2 years ago
  • 1.14.1                                ...           2 years ago
  • 1.14.0                                ...           2 years ago
  • 1.13.11                                ...           2 years ago
  • 1.13.10                                ...           2 years ago
  • 1.13.9                                ...           2 years ago
  • 1.13.8                                ...           2 years ago
  • 1.13.7                                ...           2 years ago
  • 1.13.6                                ...           2 years ago
  • 1.13.5                                ...           2 years ago
  • 1.13.4                                ...           2 years ago
  • 1.13.3                                ...           2 years ago
  • 1.13.2                                ...           2 years ago
  • 1.13.1                                ...           2 years ago
  • 1.13.0                                ...           2 years ago
  • 1.12.1                                ...           2 years ago
  • 1.12.0                                ...           2 years ago
  • 1.11.0                                ...           2 years ago
  • 1.10.0                                ...           2 years ago
  • 1.9.10                                ...           2 years ago
  • 1.9.9                                ...           2 years ago
  • 1.9.8                                ...           2 years ago
  • 1.9.7                                ...           2 years ago
  • 1.9.6                                ...           2 years ago
  • 1.9.5                                ...           2 years ago
  • 1.9.4                                ...           2 years ago
  • 1.9.3                                ...           2 years ago
  • 1.9.2                                ...           2 years ago
  • 1.9.1                                ...           2 years ago
  • 1.9.0                                ...           2 years ago
  • 1.8.2                                ...           2 years ago
  • 1.8.1                                ...           3 years ago
  • 1.8.0                                ...           3 years ago
  • 1.7.0                                ...           3 years ago
  • 1.6.4                                ...           3 years ago
  • 1.6.3                                ...           3 years ago
  • 1.6.2                                ...           3 years ago
  • 1.6.1                                ...           3 years ago
  • 1.6.0                                ...           3 years ago
  • 1.5.3                                ...           3 years ago
  • 1.5.2                                ...           3 years ago
  • 1.5.1                                ...           3 years ago
  • 1.5.0                                ...           3 years ago
  • 1.4.0                                ...           3 years ago
  • 1.3.6                                ...           3 years ago
  • 1.3.5                                ...           3 years ago
  • 1.3.4                                ...           3 years ago
  • 1.3.3                                ...           3 years ago
  • 1.3.2                                ...           3 years ago
  • 1.3.1                                ...           3 years ago
  • 1.3.0                                ...           3 years ago
  • 1.2.1                                ...           3 years ago
  • 1.2.0                                ...           3 years ago
  • 1.1.2                                ...           3 years ago
  • 1.1.1                                ...           3 years ago
  • 1.1.0                                ...           3 years ago
  • 1.0.11                                ...           3 years ago
  • 1.0.10                                ...           3 years ago
  • 1.0.9                                ...           3 years ago
  • 1.0.8                                ...           3 years ago
  • 1.0.7                                ...           3 years ago
  • 1.0.6                                ...           3 years ago
  • 1.0.5                                ...           3 years ago
  • 1.0.4                                ...           3 years ago
  • 1.0.3                                ...           3 years ago
  • 1.0.2                                ...           3 years ago
  • 1.0.1                                ...           3 years ago
  • 1.0.0                                ...           3 years ago
  • 0.6.0                                ...           3 years ago
  • 0.5.41                                ...           3 years ago
  • 0.5.40                                ...           3 years ago
  • 0.5.39                                ...           3 years ago
  • 0.5.38                                ...           3 years ago
  • 0.5.37                                ...           3 years ago
  • 0.5.36                                ...           3 years ago
  • 0.5.35                                ...           3 years ago
  • 0.5.34                                ...           3 years ago
  • 0.5.33                                ...           3 years ago
  • 0.5.32                                ...           3 years ago
  • 0.5.31                                ...           3 years ago
  • 0.5.30                                ...           3 years ago
  • 0.5.29                                ...           3 years ago
  • 0.5.28                                ...           3 years ago
  • 0.5.27                                ...           3 years ago
  • 0.5.26                                ...           3 years ago
  • 0.5.25                                ...           3 years ago
  • 0.5.24                                ...           3 years ago
  • 0.5.23                                ...           3 years ago
  • 0.5.22                                ...           3 years ago
  • 0.5.21                                ...           3 years ago
  • 0.5.20                                ...           3 years ago
  • 0.5.19                                ...           3 years ago
  • 0.5.18                                ...           3 years ago
  • 0.5.17                                ...           3 years ago
  • 0.5.16                                ...           3 years ago
  • 0.5.15                                ...           3 years ago
  • 0.5.14                                ...           3 years ago
  • 0.5.13                                ...           3 years ago
  • 0.5.12                                ...           3 years ago
  • 0.5.11                                ...           3 years ago
  • 0.5.10                                ...           3 years ago
  • 0.5.9                                ...           3 years ago
  • 0.5.8                                ...           3 years ago
  • 0.5.7                                ...           3 years ago
  • 0.5.6                                ...           4 years ago
  • 0.5.5                                ...           4 years ago
  • 0.5.4                                ...           4 years ago
  • 0.5.3                                ...           4 years ago
  • 0.5.0                                ...           4 years ago
  • 0.4.0                                ...           4 years ago
  • 0.3.0                                ...           4 years ago
  • 0.2.0                                ...           4 years ago
  • 0.1.2                                ...           4 years ago
  • 0.1.1                                ...           4 years ago
  • 0.1.0                                ...           4 years ago
Downloads
Total 0
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (28)
Dependents (2)

© 2010 - cnpmjs.org x YWFE | Home | YWFE