- index function accepts yargs instance, usage instance, and validation instance; returns command instance
addHandler(cmd, description, builder, handler)accepts the following; returns undefined- command string or full object/module
- optional help text description as string (or
falsefor hidden command) - optional options object or builder function that accepts a yargs instance; optionally returns yargs or yargs.argv
- optional handler function that accepts argv; returns anything (currently ignored)
addDirectory(dir, context, req, callerFile, opts)accepts the following; returns undefined- relative directory as string
- context object containing
commandsarray andfilesarray - require function
- path (absolute) to file of calling module (1st dir argument is relative to this)
- optional object containing
require-directoryoptions
getCommands()returns array of previously configured command strings (equivalent toObject.keys(getCommandHandlers()))getCommandHandlers()returns object mapping parsed command strings to command objects; command objects contain:originalunparsed command stringdemandedparsed required positional argsoptionalparsed optional positional argsbuilderoptions object or functionhandlerfunction
runCommand(command, yargs, parsed)accepts the following; returns inner parsed argv- parsed command string (positional args removed)
- yargs instance
- object returned from parser containing
argvobject andaliasesobject
reset()returns command instance
- based on y18n
- module encapulates
localesdir with json file per supported locale - index function accepts opts; returns i18n instance
- yargs should wrap instance to provide default impl and to pass to other modules/plugins
getLocale()returns locale as string, e.g.'en'or'en_US'setLocale(locale)accepts locale string; returns undefinedupdateLocale(obj)accepts object of locale string overrides; returns undefined
__()accepts msg key as string, msg args as any, and optional errorback function for writes; returns formatted localized msg as string__n()accepts the following; returns formatted localized msg as string- singular msg key as string
- plural msg key as string
- quantity to determine singular or plural, as integer
- arbitrary number of msg args as any
- optional errorback function for writes
'Commands:''Options:''Examples:''boolean''count''string''number''array''required''default:''choices:''generated-value''Not enough non-option arguments: got %s, need at least %s''Too many non-option arguments: got %s, maximum of %s''Missing argument value: %s'(object containing'one'and'other'keys)'Missing required argument: %s'(object containing'one'and'other'keys)'Unknown argument: %s'(object containing'one'and'other'keys)'Invalid values:''Argument: %s, Given: %s, Choices: %s''Argument check failed: %s''Implications failed:''Not enough arguments following: %s''Invalid JSON config file: %s''Path to JSON config file''Show help''Show version number''Did you mean %s?'
-
static
detailed(args, options)accepts:
- args array of strings
- yargs configuration object
returns object containing:
argvparsed args objecterrorany error encountered during parsingaliasesextended aliases object/mappingnewAliasesobject for aliases added due to camelCasingconfigurationgivenoptions.configurationobject