@oclif/command

  • Version 1.8.0
  • Published
  • 60 kB
  • 6 dependencies
  • MIT license

Install

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

Overview

oclif base command

Index

Functions

function run

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

    Classes

    class Command

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

    constructor

    constructor(argv: string[], config: any);

      property aliases

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

      property args

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

      property argv

      argv: string[];

        property config

        config: any;

          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: any;
                        • instantiate and run the command

                          Parameter this

                          Class

                          Parameter argv

                          argv

                          Parameter opts

                          options

                        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?: any,
                                      argv?: string[]
                                      ) => any;

                                        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?: any) => PromiseLike<any>;

                                                Namespaces

                                                namespace flags

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

                                                  variable string

                                                  const string: Definition<string>;

                                                    function build

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

                                                      function enum

                                                      enum: <T = string>(opts: any) => any

                                                        function help

                                                        help: (opts?: any) => any;

                                                          function option

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

                                                            function version

                                                            version: (opts?: any) => any;

                                                              type Definition

                                                              type Definition<T> = {
                                                              (
                                                              options: {
                                                              multiple: true;
                                                              } & Partial<IOptionFlag<T[]>>
                                                              ): IOptionFlag<T[]>;
                                                              (
                                                              options: (
                                                              | {
                                                              required: true;
                                                              }
                                                              | {
                                                              default: Parser.flags.Default<T>;
                                                              }
                                                              ) &
                                                              Partial<IOptionFlag<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)

                                                                            Badge

                                                                            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
                                                                              [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@oclif/command)
                                                                            • 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>