definition
The entry for gunshi command definition.
This entry point exports the following APIs and types:
define: A function to define a command.defineWithTypes: A function to define a command with specific type parameters.lazy: A function to lazily load a command.lazyWithTypes: A function to lazily load a command with specific type parameters.CommandErrorandisCommandError: An error for the failures that a command expects, and its guard.jsonArgs: The argument that a command spreads into itsargsto support--json.- Some basic type definitions, such as
Command,LazyCommand, etc.
Example
js
import { define } from 'gunshi/definition'
export default define({
name: 'say',
args: {
say: {
type: 'string',
description: 'say something',
default: 'hello!'
}
},
run: ctx => {
return `You said: ${ctx.values.say}`
}
})Functions
| Function | Description |
|---|---|
| define | Define a command. |
| defineWithTypes | Define a command with types |
| lazy | Define a lazy command. |
| lazyWithTypes | Define a lazy command with specific type parameters. |
References
Args
Re-exports Args
ArgSchema
Re-exports ArgSchema
ArgValues
Re-exports ArgValues
Command
Re-exports Command
CommandContextParams
Re-exports CommandContextParams
CommandError
Re-exports CommandError
CommandErrorOptions
Re-exports CommandErrorOptions
CommandLoader
Re-exports CommandLoader
CommandRunner
Re-exports CommandRunner
CommandRunnerResult
Re-exports CommandRunnerResult
createCommandContext
Re-exports createCommandContext
DefaultGunshiParams
Re-exports DefaultGunshiParams
ExtendContext
Re-exports ExtendContext
GunshiParams
Re-exports GunshiParams
isCommandError
Re-exports isCommandError
jsonArgs
Re-exports jsonArgs
JsonResult
Re-exports JsonResult
LazyCommand
Re-exports LazyCommand
SubCommandable
Re-exports SubCommandable
