oclif
Open CLI framework for Node.js with declarative commands, typed flags and args, plugins, and auto-generated help.
Official Documentation ↗v4 (@oclif/core). Check the official docs for the latest API surface.Installation
npm install @oclif/corepnpm add @oclif/coreMethods
No methods match this filter.
Overview
oclif is a CLI framework for Node.js with declarative commands, typed flags and args, plugins, and auto-generated help. This reference lists the most frequently used APIs with accurate signatures and runnable snippets.
Core APIs
Command— Base class for CLI commands where flags and args are declared statically.this.parse— Parses process argv into typed flags and args according to the command definition.Flags— Declares a typed flag with help metadata and optional validation.
Example
const { Command, Flags } = require('@oclif/core');
class Hello extends Command {
static flags = { name: Flags.string({ char: 'n' }) };
async run() {
const { flags } = await this.parse(Hello);
this.log('Hi ' + (flags.name || 'world'));
}
}
module.exports = Hello;
Notes
Flags and args are declared as statics, which drives parsing and help output. Plugins let commands be distributed across packages.
Verification
Run a command with a declared string flag and confirm this.parse returns its value under flags.
Errors
The following points are quoted verbatim from the official documentation. 来源:https://oclif.io/docs/introduction · 取证方式:HTTP GET 官方 README/文档页(HTML 去标签) · 抓取时间:2026-11-07T13:51:18.481Z. Any error type, throw condition or recovery step not stated there is left unspecified; this page does not infer exception classes or return values.
- It's designed to be extensible so that you can easily add plugins, such as the update warning plugin , or build your own for users to install at runtime. (https://oclif.io/docs/introduction)
FAQ
- How do I add a plugin?
- List it under oclif.plugins in package.json or install it; oclif discovers commands from each plugin automatically.
- How is help generated?
- oclif derives help from the static flags, args, description, and examples on each command class.
- How do I run a command programmatically?
- Use the run entry from @oclif/core with a config root and argv array, or call the command class run method directly.
Report a problem with this API docOpens a pre-filled issue on GitHub.