oclif (Open CLI Framework) is a robust and extensible framework for building command-line interface (CLI) applications using Node.js and TypeScript. It provides a structured approach to CLI development, handling common tasks like command parsing, argument and flag definition, help generation, and plugin management. Currently in its 4.x major version, oclif receives frequent maintenance updates, primarily bug fixes and dependency bumps, indicating active development. Key differentiators include its extensibility via plugins, comprehensive documentation, and its adoption by major projects such as the Salesforce CLI and Heroku CLI. It's designed to support both single-command CLIs and multi-command CLIs with ease, abstracting away much of the boilerplate associated with CLI creation.
npm install oclifVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to define a basic 'hello' command with arguments and flags within an oclif CLI, and how to create a new oclif project.
Replace calls to `oclif multi`, `oclif plugin`, or `oclif single` with `oclif generate <cli-name>`.
Update scripts and documentation to use the new command names: `oclif generate:hook` and `oclif generate:command`.
Ensure your development and production environments use Node.js 18 or a newer LTS version. Use a tool like `nvm` to manage Node versions.
Always use `import` statements for oclif components. Ensure your `package.json` specifies `"type": "module"` if not already set, or use `.mjs` file extensions for ESM files.
Ensure you are using `import { Command } from '@oclif/core';` for ESM modules. If strictly in CommonJS, consider transpiling or updating your project to ESM. Most modern oclif usage expects ESM.Update your Node.js installation to version 18 or greater. Use `nvm install 18` and `nvm use 18` or similar version management tools.
Consult the migration guide from v1 to v2. Use `oclif generate` for creating new CLIs/plugins, and `oclif generate:hook` or `oclif generate:command` for generating specific components.