Skip to main content

Generator Commands

oclif generate NAME

Generate a new CLI

USAGE
$ oclif generate NAME [-y] [--author <value>] [--bin <value>] [--description <value>] [--license <value>]
[--module-type CommonJS|ESM] [--name <value>] [--owner <value>] [--package-manager npm|yarn] [--repository <value>]
[-d <value>]

ARGUMENTS
NAME Directory name of new project.

FLAGS
-d, --output-dir=<value> Directory to build the CLI in.
-y, --yes Use defaults for all prompts. Individual flags will override defaults.
--author=<value> Supply answer for prompt: Author
--bin=<value> Supply answer for prompt: Command bin name the CLI will export
--description=<value> Supply answer for prompt: Description
--license=<value> Supply answer for prompt: License
--module-type=<option> Supply answer for prompt: Select a module type
<options: CommonJS|ESM>
--name=<value> Supply answer for prompt: NPM package name
--owner=<value> Supply answer for prompt: Who is the GitHub owner of repository
(https://github.com/OWNER/repo)
--package-manager=<option> Supply answer for prompt: Select a package manager
<options: npm|yarn>
--repository=<value> Supply answer for prompt: What is the GitHub name of repository
(https://github.com/owner/REPO)

DESCRIPTION
Generate a new CLI

This will clone the template repo and update package properties. For CommonJS, the 'oclif/hello-world' template will
be used and for ESM, the 'oclif/hello-world-esm' template will be used.

EXAMPLES
Generate a new CLI with prompts for all properties

$ oclif generate my-cli

Automatically accept default values for all prompts

$ oclif generate my-cli --yes

Supply answers for specific prompts

$ oclif generate my-cli --module-type CommonJS --author "John Doe"

Supply answers for specific prompts and accept default values for the rest

$ oclif generate my-cli --module-type CommonJS --author "John Doe" --yes

See code: src/commands/generate.ts

oclif generate command NAME

Add a command to an existing CLI or plugin.

USAGE
$ oclif generate command NAME [-y] [--commands-dir <value>] [--force]

ARGUMENTS
NAME name of command

FLAGS
--commands-dir=<value> [default: src/commands] The directory to create the command in.
--force Overwrite existing files.

DESCRIPTION
Add a command to an existing CLI or plugin.

See code: src/commands/generate/command.ts

oclif generate hook NAME

Add a hook to an existing CLI or plugin.

USAGE
$ oclif generate hook NAME [-y] [--event <value>] [--force]

ARGUMENTS
NAME Name of hook (snake_case).

FLAGS
--event=<value> [default: init] Event to run hook on.
--force Overwrite existing files.

DESCRIPTION
Add a hook to an existing CLI or plugin.

See code: src/commands/generate/hook.ts