@nodecfdi/adonisjs-sat-catalogs
    Preparing search index...

    Hierarchy

    • BaseCommand
      • default
    Index

    Constructors

    • Parameters

      • app: ApplicationService
      • kernel: Kernel
      • parsed: any
      • ui: {
            colors: Colors;
            icons: {
                bullet: string;
                cross: string;
                info: string;
                nodejs: string;
                pointer: string;
                squareSmallFilled: string;
                tick: string;
                warning: string;
            };
            instructions: () => Instructions;
            logger: Logger;
            sticker: () => Instructions;
            table: (tableOptions?: Partial<TableOptions>) => Table;
            tasks: (tasksOptions?: Partial<TaskManagerOptions>) => TaskManager;
            switchMode(modeToUse: "silent" | "raw" | "normal"): void;
            useColors(colorsToUse: Colors): void;
            useRenderer(rendererToUse: RendererContract): void;
        }
      • prompt: Prompt

      Returns default

    Properties

    app: ApplicationService
    destination?: string
    error?: any

    The error raised at the time of the executing the command. The value is undefined if no error is raised.

    exitCode?: number

    The exit code for the command

    hydrated: boolean

    Check if a command has been hypdrated

    kernel: Kernel
    override?: boolean
    parsed: any
    prompt: Prompt
    result?: any

    The result property stores the return value of the "run" method (unless commands sets it explicitly)

    ui: {
        colors: Colors;
        icons: {
            bullet: string;
            cross: string;
            info: string;
            nodejs: string;
            pointer: string;
            squareSmallFilled: string;
            tick: string;
            warning: string;
        };
        instructions: () => Instructions;
        logger: Logger;
        sticker: () => Instructions;
        table: (tableOptions?: Partial<TableOptions>) => Table;
        tasks: (tasksOptions?: Partial<TaskManagerOptions>) => TaskManager;
        switchMode(modeToUse: "silent" | "raw" | "normal"): void;
        useColors(colorsToUse: Colors): void;
        useRenderer(rendererToUse: RendererContract): void;
    }
    aliases: string[]

    A collection of aliases for the command

    args: Argument[]

    Registered arguments

    booted: boolean
    commandName: "sat-catalogs:create-update" = 'sat-catalogs:create-update'

    The command name one can type to run the command

    description: "Download sources from phpcfdi/resources-sat-catalogs and create or update a sqlite3 database" = 'Download sources from phpcfdi/resources-sat-catalogs and create or update a sqlite3 database'

    The command description

    flags: Flag[]

    Registered flags

    help: string[] = ...

    The help text for the command. Help text can be a multiline string explaining the usage of command

    instanceMacros: Set<{ key: string | number | symbol; value: unknown }>

    Set of instance properties that will be added to each instance during construction. Each entry contains a key and value pair representing the property name and its value.

    options: CommandOptions = ...

    Accessors

    • get args(): Argument[]

      Reference to the command args

      Returns Argument[]

    • get colors(): Colors

      Add colors to console messages

      Returns Colors

    • get commandName(): string

      Reference to the command name

      Returns string

    • get flags(): Flag[]

      Reference to the command flags

      Returns Flag[]

    • get isMain(): boolean

      Is the current command the main command executed from the CLI

      Returns boolean

    • get logger(): Logger

      Logger to log messages

      Returns Logger

    • get options(): CommandOptions

      Reference to the command options

      Returns CommandOptions

    • get startApp(): boolean | undefined

      Returns boolean | undefined

    • get staysAlive(): boolean | undefined

      Returns boolean | undefined

    Methods

    • Assert the command exists with a given exit code

      Parameters

      • code: number

      Returns void

    • Assert the command exists with non-zero exit code

      Returns void

    • Assert command to log the expected message

      Parameters

      • message: string
      • Optionalstream: "stdout" | "stderr"

      Returns void

    • Assert command to log the expected message

      Parameters

      • matchingRegex: RegExp
      • Optionalstream: "stdout" | "stderr"

      Returns void

    • Assert the command exists with a given exit code

      Parameters

      • code: number

      Returns void

    • Assert the command exists with zero exit code

      Returns void

    • Assert the command prints a table to stdout

      Parameters

      • rows: string[][]

      Returns void

    • The completed method is the method invoked after the command finishes or results in an error.

      You can access the command error using the this.error property. Returning true from completed method supresses the error reporting to the kernel layer.

      Returns Promise<boolean | undefined>

    • Creates the codemods module to modify source files

      Returns Promise<Codemods>

    • Executes the command

      Returns Promise<any>

    • Hydrate command by setting class properties from the parsed output

      Returns void

    • The interact template method is used to display the prompts to the user. The method is called after the prepare method.

      Parameters

      • ..._: any[]

      Returns any

    • The prepare template method is used to prepare the state for the command. This is the first method executed on a given command instance.

      Returns void

    • Terminate the app. A command should prefer calling this method over the "app.terminate", because this method only triggers app termination when the current command is in the charge of the process.

      Returns Promise<void>

    • JSON representation of the command

      Returns {
          args: any[];
          commandName: string;
          error: any;
          exitCode: number | undefined;
          flags: { [argName: string]: any };
          options: CommandOptions;
          result: any;
      }

    • Define static properties on the class. During inheritance, certain properties must inherit from the parent.

      Returns void

    • Specify the argument the command accepts. The arguments via the CLI will be accepted in the same order as they are defined.

      Mostly, you will be using the @args decorator to define the arguments.

      Command.defineArgument('entity', { type: 'string' })
      

      Parameters

      • name: string
      • options: Partial<Argument> & { type: "string" | "spread" }

      Returns void

    • Specify a flag the command accepts.

      Mostly, you will be using the @flags decorator to define a flag.

      Command.defineFlag('connection', { type: 'string', required: true })
      

      Parameters

      • name: string
      • options: Partial<Flag> & { type: "string" | "number" | "boolean" | "array" }

      Returns void

    • Returns the options for parsing flags and arguments

      Parameters

      • Optionaloptions: FlagsParserOptions

      Returns {
          argumentsParserOptions: ArgumentsParserOptions[];
          flagsParserOptions: Required<FlagsParserOptions>;
      }

    • Adds a getter property to the class prototype using Object.defineProperty. Getters are computed properties that are evaluated each time they are accessed, unless the singleton flag is enabled.

      Type Parameters

      • T extends new (...args: any[]) => any
      • K extends string | number | symbol

      Parameters

      • this: T
      • name: K

        The name of the getter property

      • accumulator: () => InstanceType<T>[K]

        Function that computes and returns the property value

      • Optionalsingleton: boolean

        If true, the getter value is cached after first access

      Returns void

      // Add a regular getter
      MyClass.getter('timestamp', function() {
      return Date.now()
      })

      // Add a singleton getter (cached after first access)
      MyClass.getter('config', function() {
      return loadConfig()
      }, true)

      const instance = new MyClass()
      instance.timestamp // Computed each time
      instance.config // Computed once, then cached
    • Adds an instance property that will be assigned to each instance during construction. Unlike macros which are added to the prototype, instance properties are unique to each instance.

      Type Parameters

      • T extends new (...args: any[]) => any
      • K extends string | number | symbol

      Parameters

      • this: T
      • name: K

        The name of the property to add to instances

      • value: InstanceType<T>[K]

        The value to assign to the property on each instance

      Returns void

      // Add an instance method
      MyClass.instanceProperty('save', function() {
      console.log('Saving...', this.id)
      })

      const { save } = new MyClass()
      save()
    • Adds a macro (property or method) to the class prototype. Macros are standard properties that get added to the class prototype, making them available on all instances of the class.

      Type Parameters

      • T extends new (...args: any[]) => any
      • K extends string | number | symbol

      Parameters

      • this: T
      • name: K

        The name of the property or method to add

      • value: InstanceType<T>[K]

        The value to assign to the property or method

      Returns void

      // Add a property macro
      MyClass.macro('version', '1.0.0')

      // Add a method macro
      MyClass.macro('greet', function() {
      return 'Hello!'
      })

      const instance = new MyClass()
      instance.version // "1.0.0"
      instance.greet() // "Hello!"
    • Serializes the command to JSON. The return value satisfies the CommandMetaData

      Returns CommandMetaData

    • Validate the yargs parsed output againts the command.

      Parameters

      • parsedOutput: any

      Returns void