What is @oclif/plugin-which?
@oclif/plugin-which is a plugin for the Oclif CLI framework that helps in locating the path of a command within the CLI. It is useful for debugging and ensuring that the correct command is being executed.
What are @oclif/plugin-which's main functionalities?
Locate Command Path
This feature allows you to locate the path of a specific command within your CLI. The code sample demonstrates how to use the @oclif/plugin-which to find the path of 'mycommand' and log it.
const { Command } = require('@oclif/command');
const which = require('@oclif/plugin-which');
class MyCommand extends Command {
async run() {
const commandPath = await which('mycommand');
this.log(`Command path: ${commandPath}`);
}
}
MyCommand.run();
Other packages similar to @oclif/plugin-which
which
The 'which' package is a standalone utility for finding the path of an executable in the system's PATH. It is similar to @oclif/plugin-which but is not specific to the Oclif framework. It can be used in any Node.js application to locate executables.
command-exists
The 'command-exists' package checks if a command-line command exists in the system's PATH. It is similar to @oclif/plugin-which in that it helps locate commands, but it focuses on checking the existence of commands rather than providing their paths.
@oclif/plugin-which
find which plugin a command is in
Usage
$ npm install -g @oclif/plugin-which
$ oclif-example COMMAND
running command...
$ oclif-example (--version)
@oclif/plugin-which/3.2.20 linux-x64 node-v22.11.0
$ oclif-example --help [COMMAND]
USAGE
$ oclif-example COMMAND
...
Commands
oclif-example which
Show which plugin a command is in.
USAGE
$ oclif-example which [--json]
GLOBAL FLAGS
--json Format output as json.
DESCRIPTION
Show which plugin a command is in.
EXAMPLES
See which plugin the `help` command is in:
$ oclif-example which help
Use colon separators.
$ oclif-example which foo:bar:baz
Use spaces as separators.
$ oclif-example which foo bar baz
Wrap command in quotes to use spaces as separators.
$ oclif-example which "foo bar baz"
See code: src/commands/which.ts
Contributing
See contributing guide