Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "onCommand"

Index

Type aliases

OnCommand

OnCommand<P>: (ctx: HandlerContext, parameters: P) => Promise<HandlerResult> | Promise<any>

Handle the given command. Parameters will have been set on a fresh parameters instance before invocation

param

context from which GraphQL client can be obtained, messages can be sent etc.

returns

a Promise of a HandlerResult, containing a status code, or anything else representing success.

Type parameters

  • P = undefined

Type declaration

Functions

addRegExIntentAnchors

  • addRegExIntentAnchors(intent: RegExp): string
  • Given a regex used for an intent, add anchors to it if missing. Additionally, wraps the new anchors in match groups along with the original intent for access later.

    Parameters

    • intent: RegExp

    Returns string

commandHandlerFrom

  • Create a HandleCommand instance with the appropriate metadata wrapping the given function

    Type parameters

    • P

    Parameters

    • h: OnCommand<P>
    • factory: Maker<P>
    • Default value name: string = h.name || `Command${generateHash(h.toString())}`
    • Default value description: string = name
    • Default value intent: string | string[] | RegExp = []
    • Default value tags: string | string[] = []
    • Default value autoSubmit: boolean = false
    • Optional question: QuestionStyle

    Returns HandleCommand<P> & CommandHandlerMetadata

parseRegExIntent

  • parseRegExIntent(intent: string | string[] | RegExp): string | string[]
  • Parse command handler intent. If the incoming intent is a RegExp convert it to a string pattern. Otherwise, pass existing intent through.

    Parameters

    • intent: string | string[] | RegExp

    Returns string | string[]

Generated using TypeDoc