Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Kawkah

Hierarchy

Index

Constructors

constructor

Properties

Protected _name

_name: string

core

Accessors

Protected _command

Protected assert

  • get assert(): assert

middleware

Protected utils

Methods

Protected _option

  • Creates option flag or option arg.

    NOTE: if tokens are passed the name is parsed in this case --user.name will be seen as user with alias name when not using tokens e.g. user.name it is seen as a named config for a nested property.

    Parameters

    • name: string

      the flag/arg name or tokens.

    • describe: string | IKawkahOption

      the description or config object.

    • type: KawkahOptionType

      the option's type.

    • def: any

      the option's default value.

    • Optional argOrAction: boolean | KawkahResultAction

    Returns Kawkah & KawkahCommandBase<Kawkah>

abort

about

action

actionFor

  • Adds action for option flag, only available on default command. Command actions when present supersede these callbacks.

    example

    .actionFor('version', (result) => { // do something });

    Parameters

    • option: string

      the option name to add action to.

    • fn: KawkahResultAction

      the action handler.

    Returns this

alias

aliasFor

arg

args

arrayFor

booleanFor

catch

  • Enables catch handler called showing help on errors.

    example

    .catch();

    Returns Kawkah

  • Enables/Disables catch handler called showing help on errors.

    example

    .catch(false);

    Parameters

    • enabled: boolean

      boolean value to enable or disable handler.›

    Returns Kawkah

  • Enables catch handler with custom string on errors.

    Parameters

    • text: string

      the string to be displayed.

    Returns Kawkah

  • A Kawkah callback action to be called when no command is found.

    example

    .catch((result, context) => { // do something on no command/option });

    Parameters

    Returns Kawkah

  • Enables catch handler on errors calling an existing command.

    example

    .catch('some_known_command_name', true);

    Parameters

    • command: string

      an existing command name.

    • isCommand: boolean

      indicates should lookup as a command name.

    Returns Kawkah

coerceFor

command

  • Creates command with usage tokens or gets existing by name.

    Parameters

    • nameOrUsage: string

      usage tokens to be parsed.

    Returns KawkahCommand

  • Creates a new command from name & description.

    Parameters

    • name: string

      the command name.

    • describe: string

    Returns KawkahCommand

  • Creates a new command as external command.

    Parameters

    • name: string

      the command name.

    • external: boolean

      the executable path or true to use name.

    Returns KawkahCommand

  • Creates a new command with action.

    Parameters

    • name: string

      the command name.

    • action: KawkahAction

      the action to call on command matched.

    Returns KawkahCommand

  • Creates a new command using config object.

    Parameters

    • name: string

      the command name.

    • config: IKawkahCommand

      the command's configuration object.

    Returns KawkahCommand

  • Creates a new command from name and action.

    Parameters

    • name: string

      the command name.

    • describe: string
    • action: KawkahAction

      the action to execute on matched command.

    Returns KawkahCommand

  • Creates a new command from name, description as external command.

    Parameters

    • name: string

      the command name.

    • describe: string
    • external: string | boolean

      external command, executable path or true to use name.

    Returns KawkahCommand

  • Creates a new command from name, description and action.

    Parameters

    • name: string

      the command name.

    • describe: string
    • external: string | boolean
    • action: KawkahAction

      the action to execute on matched command.

    Returns KawkahCommand

completionsFor

configAbout

  • configAbout(): any
  • configAbout(enabled: boolean): any
  • configAbout(name: string | string[], describe?: string): any
  • Enables about option/feature with defaults.

    Returns any

  • Enables or disables about option/feature.

    Parameters

    • enabled: boolean

      boolean enable/disables about.

    Returns any

  • Enables about feature optionally sets the option and description to be used.

    Parameters

    • name: string | string[]

      the option name for displaying command about.

    • Optional describe: string

      the option description to display in help.

    Returns any

configCompletions

  • Adds tab completions to your app using all defaults.

    Returns Kawkah

  • Adds tab completions with defaults or disables.

    example

    .completions(false);

    Parameters

    • enabled: boolean

      enables with defaults or disables completions.

    Returns Kawkah

  • Adds tab completions to app with custom name.

    example

    .completions('completions');

    Parameters

    • name: string

      the name of the completions command.

    Returns Kawkah

  • Adds tab completions to app with name and custom handler function for generating completions.

    example

    .completions('completions', HandlerFunction);

    Parameters

    • name: string

      the name of the completions command.

    • fn: KawkahCompletionsHandler

      optional custom handler for building completions.

    Returns Kawkah

  • Adds tab completions to your app with named completions command, custom description, custom handler and bash script template.

    example

    Function: a custom completions handler function. Template: a custom template for generating completions script. .completions('completions', 'Some description', HandlerFunction, 'Template')

    Parameters

    • name: string

      the name of the completions command.

    • describe: string

      the help description for completions.

    • Optional fn: KawkahCompletionsHandler

      optional custom handler for building completions.

    • Optional template: string

      a custom template for generating completions script.

    Returns Kawkah

configHelp

  • Enables help with defaults.

    Returns Kawkah

  • Toggles help option enabled or disabled.

    Parameters

    • enabled: boolean

      bool value to enable/disable help.

    Returns Kawkah

  • Enables help with default option using custom help handler.

    Parameters

    Returns Kawkah

  • Enables help with custom option(s) names with optional help handler.

    Parameters

    • name: string | string[]

      a string or array of string option names.

    • Optional fn: KawkahHelpHandler

      optional help handler method for displaying help.

    Returns Kawkah

  • Enables help with custom option(s) names with optional help handler.

    Parameters

    • name: string | string[]

      a string or array of string option names.

    • describe: string

      the description for help option.

    • Optional fn: KawkahHelpHandler

      optional help handler method for displaying help.

    Returns Kawkah

configLogger

configVersion

  • configVersion(): Kawkah
  • configVersion(version: string): Kawkah
  • configVersion(enabled: boolean): Kawkah
  • configVersion(name: string[], describe?: string, version?: string): Kawkah
  • Sets version option with all defaults.

    Returns Kawkah

  • Sets version with custom version value.

    example

    .setVersion('1.2.6-alpha');

    Parameters

    • version: string

      the value to set version to.

    Returns Kawkah

  • Enables or disables version.

    example

    .setVersion(false);

    Parameters

    • enabled: boolean

      bool value to enable/disable version.

    Returns Kawkah

  • Sets version with custom option keys with description and custom version.

    Parameters

    • name: string[]

      the option keys to use for version.

    • Optional describe: string

      the description for help.

    • Optional version: string

      a custom value to set version to.

    Returns Kawkah

context

contextFor

defaultFor

demandFor

denyFor

describe

describeFor

error

  • error(message: any, ...args: any[]): Kawkah
  • Logs an Error message.

    Parameters

    • message: any

      a message to be logged.

    • Rest ...args: any[]

      optional format arguments.

    Returns Kawkah

example

exec

exit

  • exit(code?: number): void
  • Exits Kawkah.

    Parameters

    • Default value code: number = 0

      the process exit code.

    Returns void

extendFor

external

flag

flags

footer

  • footer(footer: string, align?: "left" | "center" | "right"): this
  • Sets a footer for help.

    Parameters

    • footer: string

      a string to display as help footer.

    • Optional align: "left" | "center" | "right"

      the alignment for the above string.

    Returns this

group

  • Gets a group by name.

    Parameters

    • name: any

      the name of the group to get.

    Returns IKawkahGroup

  • Sets a group to enabled or disabled.

    example

    .group('My Group', false);

    Parameters

    • name: string

      the name of the group.

    • enabled: boolean

      enable/disable the group.

    Returns Kawkah

  • Assigns items to a group.

    Parameters

    • name: string

      the name of the group.

    • Rest ...items: string[]

      list of items for the group.

    Returns Kawkah

  • Sets a group using config object.

    example

    .group('My Group', { // group options here });

    Parameters

    • name: string

      the name of the group.

    • config: IKawkahGroup

      a configuration object for the group.

    Returns Kawkah

  • Sets group by command binding options or filtered options.

    Parameters

    • name: string

      the name of the group to be set.

    • command: string
    • include: true | string[]

      true or array of option keys to include.

    Returns IKawkahGroup

header

  • header(header: string, align?: "left" | "center" | "right"): this
  • Sets a header for help.

    Parameters

    • header: string

      a string to display as help header.

    • Optional align: "left" | "center" | "right"

      the alignment for the above string.

    Returns this

help

helpFor

listen

  • Parse arguments and listen for known command actions.

    example

    .listen();

    Returns IKawkahResult

  • Parse arguments and listen for known command actions, show result.

    example

    .listen(true);

    Parameters

    • show: boolean

      when true result is output to console helpful when testing.

    Returns IKawkahResult

  • Listens for matching commands after parsing arguments.

    example

    .listen(['command', '--dir', '/some/dir']); .listen(['command', '--dir', '/some/dir'], true);

    Parameters

    • argv: string | string[]

      the optional arguments to be parsed.

    • Optional show: boolean

      when true result is output to console helpful when testing.

    Returns IKawkahResult

locale

  • locale(): string
  • locale(locale: string): Kawkah
  • Gets the current locale.

    Returns string

  • Sets the locale.

    Parameters

    • locale: string

      the locale used for messaging.

    Returns Kawkah

log

  • Logs an empty line.

    Returns Kawkah

  • Logs an error.

    Parameters

    • err: Error

      the error to be logged.

    Returns Kawkah

  • Logs a message with optional formatting.

    Parameters

    • message: any

      a message to be logged.

    • Rest ...args: any[]

      rest param of arguments used in formatting.

    Returns Kawkah

maxArgs

  • maxArgs(count: number): this
  • The maximum args allowed for the command.

    example

    .maxArgs(2);

    Parameters

    • count: number

      the count number.

    Returns this

maxFlags

  • maxFlags(count: number): this
  • The maximum flags allowed for the command.

    example

    .maxFlags(2);

    Parameters

    • count: number

      the count number.

    Returns this

minArgs

  • minArgs(count: number): this
  • The minimum args allowed for the command.

    example

    .minArgs(2);

    Parameters

    • count: number

      the count number.

    Returns this

minFlags

  • minFlags(count: number): this
  • The minimum flags allowed for the command.

    example

    .minFlags(2);

    Parameters

    • count: number

      the count number.

    Returns this

name

  • name(): string
  • name(name: string): Kawkah
  • Sets the name of your cli app.

    Returns string

  • Sets the name of your cli app.

    Parameters

    • name: string

      the app name.

    Returns Kawkah

notify

  • notify(message: any, ...args: any[]): Kawkah
  • Logs a Notify message.

    Parameters

    • message: any

      a message to be logged.

    • Rest ...args: any[]

      optional format arguments.

    Returns Kawkah

numberFor

ok

  • ok(message: any, ...args: any[]): Kawkah
  • Logs an OK message.

    Parameters

    • message: any

      a message to be logged.

    • Rest ...args: any[]

      optional format arguments.

    Returns Kawkah

options

parse

  • Parses process.argv arguments with validation enabled.

    example

    .parse();

    Returns IKawkahResult

  • Parses specified arguments optionally enabling or disabling validation.

    example

    .parse(['command', '--dir', '/some/dir']); .parse(['command', '--dir', '/some/dir'], false);

    Parameters

    • argv: string | string[]

      the arguments to be parsed.

    Returns IKawkahResult

requiredFor

result

showHelp

  • showHelp(...groups: string[]): void
  • Shows all help or by group name.

    Parameters

    • Rest ...groups: string[]

      optionally specify help groups to be shown.

    Returns void

skip

skipFor

spread

  • Toggles spreading action args in positional order, missing args are null.

    @ { _: ['file', 'dir', null ]} >> .action(file, dir, null, result) {}

    Parameters

    • Default value spread: boolean = true

      bool value indicating if should spread args.

    Returns Kawkah & KawkahCommandBase<Kawkah>

strict

  • strict(enabled?: boolean): Kawkah
  • Enforces option descriptions, requires command or option on input and also outputs error on anonymous values.

    Parameters

    • Default value enabled: boolean = true

    Returns Kawkah

stringFor

terminate

  • terminate(enabled?: boolean): Kawkah
  • Sets terminate to exit process on help, version and errors.

    Parameters

    • Default value enabled: boolean = true

    Returns Kawkah

theme

trace

  • trace(option?: string | boolean): Kawkah
  • Enables --trace option to enable stacktrace for errors on the fly.

    Parameters

    • Optional option: string | boolean

      the name of the trace option.

    Returns Kawkah

typeFor

validateFor

variadicFor

warning

  • warning(message: any, ...args: any[]): Kawkah
  • Logs a Warning message.

    Parameters

    • message: any

      a message to be logged.

    • Rest ...args: any[]

      optional format arguments.

    Returns Kawkah

Generated using TypeDoc