talira

Salesforce's open CLI framework for building Node.js command-line tools

open sourceMITfree

oclif (Open CLI Framework) is a framework for building command-line tools in Node.js, from single-command tools with a few flags to large CLIs with subcommands. It grew out of the Salesforce CLI and was generalized for any CLI. The framework (@oclif/core) parses flags and arguments, loads only the command being run so large CLIs start as fast as small ones, generates --help and README documentation, supports plugins, lifecycle hooks and autocomplete, and is written in TypeScript. The companion oclif CLI scaffolds new CLIs and plugins, generates commands and hooks, and packages a CLI into installers for macOS, Windows and Debian that don't need Node installed, with optional auto-updates.

Problems it solves

  • build a Node.js command-line tool with subcommands and flags
  • scaffold a TypeScript CLI with tests and help output
  • ship a Node CLI as an installer that doesn't need Node installed

Features

  • flag and argument parsing
  • loads only the command being run, so large CLIs start fast
  • auto-generated --help and README docs
  • plugins, lifecycle hooks and autocomplete
  • a generator that scaffolds TypeScript CLIs with tests
  • packages CLIs into macOS, Windows and Debian installers

Limitations

  • It supports Node 18 and later (the LTS versions).1

Alternatives

The same job

These do what oclif does.

  1. Commander.js The complete solution for Node.js command-line interfaces
  2. yargs Parse command-line arguments and build CLIs in Node.js
  3. meow Small helper for building Node.js command-line apps
  4. Inquirer.js Interactive command-line prompts for Node.js
  5. minimist Minimal command-line argument parser for Node.js

Compare oclif with the top 3