• Version 1.8.36
  • Published
  • 22.6 kB
  • 6 dependencies
  • MIT license


npm i @oclif/command
yarn add @oclif/command
pnpm add @oclif/command


oclif base command



function run

run: (argv?: string[], options?: Config.LoadOptions) => PromiseLike<any>;


    class Command

    abstract class Command {}
    • An abstract class which acts as the base for each command in your project.


    constructor(argv: string[], config: Config.IConfig);

      property aliases

      static aliases: string[];
      • An array of aliases for this command

      property args

      static args?: Parser.args.Input;
      • An order-dependent array of arguments for the command

      property argv

      argv: string[];

        property config

        config: Config.IConfig;

          property ctor

          readonly ctor: typeof Command;

            property debug

            protected debug: (...args: any[]) => void;

              property description

              static description: string;
              • The tweet-sized description for your class, used in a parent-commands sub-command listing and as the header for the command help

              property examples

              static examples: string[];
              • An array of example strings to show at the end of the command's help

              property flags

              static flags?: flags.Input<any>;
              • A hash of flags for the command

              property help

              static help: string;

                property hidden

                static hidden: boolean;
                • hide the command from help?

                property id

                static id: string;
                • A command ID, used mostly in error or verbose reporting

                property id

                id: string;

                  property parse

                  static parse: boolean;

                    property parserOptions

                    static parserOptions: {};

                      property plugin

                      static plugin: any;

                        property run

                        static run: Config.Command.Class;
                        • instantiate and run the command

                          Parameter this


                          Parameter argv


                          Parameter opts




                        property strict

                        static strict: boolean;
                        • When set to false, allows a variable amount of arguments

                        property title

                        static title: string;

                          property usage

                          static usage: string | string[];
                          • An override string (or strings) for the default usage documentation

                          method catch

                          protected catch: (err: any) => Promise<any>;

                            method error

                            error: {
                            input: string | Error,
                            options: { code?: string; exit: false } & PrettyPrintableError
                            ): void;
                            (input: string | Error, options?: any): never;

                              method exit

                              exit: (code?: number) => never;

                                method finally

                                protected finally: (_: Error | undefined) => Promise<any>;

                                  method init

                                  protected init: () => Promise<any>;

                                    method log

                                    log: (message?: string, ...args: any[]) => void;

                                      method parse

                                      protected parse: <F, A extends { [name: string]: any }>(
                                      options?: Parser.Input<F>,
                                      argv?: string[]
                                      ) => Parser.Output<F, A>;

                                        method run

                                        abstract run: () => PromiseLike<any>;
                                        • actual command run code goes here

                                        method warn

                                        warn: (input: string | Error) => void;

                                          class Main

                                          class Main extends Command {}

                                            method init

                                            init: () => Promise<any>;

                                              method run

                                              static run: (argv?: string[], options?: Config.LoadOptions) => PromiseLike<any>;


                                                namespace flags

                                                module 'lib/flags.d.ts' {}

                                                  variable string

                                                  const string: Definition<string>;

                                                    function build

                                                    build: {
                                                    defaults: { parse: IOptionFlag<T>['parse'] } & Partial<IOptionFlag<T>>
                                                    ): Definition<T>;
                                                    (defaults: Partial<any>): Definition<string>;

                                                      function enum

                                                      enum: <T = string>(opts: Parser.flags.EnumFlagOptions<T>) => any

                                                        function help

                                                        help: (
                                                        opts?: Parser.flags.IBooleanFlag<boolean>
                                                        ) => Parser.flags.IBooleanFlag<void>;

                                                          function option

                                                          option: <T>(
                                                          options: { parse: IOptionFlag<T>['parse'] } & Partial<IOptionFlag<T>>
                                                          ) => IOptionFlag<T | undefined>;

                                                            function version

                                                            version: (
                                                            opts?: Parser.flags.IBooleanFlag<boolean>
                                                            ) => Parser.flags.IBooleanFlag<void>;

                                                              type Definition

                                                              type Definition<T> = {
                                                              options: {
                                                              multiple: true;
                                                              } & Partial<IOptionFlag<T[]>>
                                                              ): IOptionFlag<T[]>;
                                                              options: (
                                                              | {
                                                              required: true;
                                                              | {
                                                              default: Parser.flags.Default<T>;
                                                              ) &
                                                              ): IOptionFlag<T>;
                                                              (options?: Partial<IOptionFlag<T>>): IOptionFlag<T | undefined>;

                                                                type ICompletion

                                                                type ICompletion = {
                                                                skipCache?: boolean;
                                                                cacheDuration?: number;
                                                                cacheKey?(ctx: ICompletionContext): Promise<string>;
                                                                options(ctx: ICompletionContext): Promise<string[]>;

                                                                  type ICompletionContext

                                                                  type ICompletionContext = {
                                                                  args?: {
                                                                  [name: string]: string;
                                                                  flags?: {
                                                                  [name: string]: string;
                                                                  argv?: string[];
                                                                  config: IConfig;

                                                                    type IFlag

                                                                    type IFlag<T> = Parser.flags.IBooleanFlag<T> | IOptionFlag<T>;

                                                                      type Input

                                                                      type Input<T extends Output> = {
                                                                      [P in keyof T]: IFlag<T[P]>;

                                                                        type IOptionFlag

                                                                        type IOptionFlag<T> = Parser.flags.IOptionFlag<T> & {
                                                                        completion?: ICompletion;

                                                                          type Output

                                                                          type Output = Parser.flags.Output;

                                                                            Package Files (4)

                                                                            Dependencies (6)

                                                                            Dev Dependencies (17)

                                                                            Peer Dependencies (1)


                                                                            To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                            You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@oclif/command.

                                                                            • Markdown
                                                                            • HTML
                                                                              <a href="https://www.jsdocs.io/package/@oclif/command"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>