Skip to content

gunshi / default

default

gunshi cli entry point.

This entry point exports the bellow APIs and types:

  • cli: The main CLI function to run the command, included global options and usage renderer built-in plugins.
  • define: A function to define a command.
  • lazy: A function to lazily load a command.
  • plugin: A function to create a plugin.
  • args-tokens utilities, parseArgs and resolveArgs for parsing command line arguments.
  • Some basic type definitions, such as CommandContext, Plugin, PluginContext, etc.

Example

js
import { cli } from 'gunshi'

Variables

VariableDescription
ANONYMOUS_COMMAND_NAME-

Functions

FunctionDescription
cliRun the command.
parseArgsParse command line arguments.
pluginDefine a plugin
resolveArgsResolve command line arguments.

Classes

ClassDescription
DefaultTranslationDefault implementation of TranslationAdapter.

Interfaces

InterfaceDescription
ArgsAn object that contains argument schema.
ArgSchemaAn argument schema definition for command-line argument parsing.
ArgTokenArgument token.
CliOptionsCLI options of cli function.
CommandCommand interface.
CommandContextCommand context. Command context is the context of the command execution.
CommandContextExtensionCommand context extension
CommandEnvironmentCommand environment.
GunshiParamsGunshi unified parameter type.
PluginContextGunshi plugin context interface.
PluginDependencyPlugin dependency definition
PluginOptionsPlugin definition options
PluginWithExtensionPlugin return type with extension, which includes the plugin ID, name, dependencies, and extension. This type is used to define a plugin at plugin function.
PluginWithoutExtensionPlugin return type without extension, which includes the plugin ID, name, and dependencies, but no extension. This type is used to define a plugin at plugin function without extension.
RenderingOptionsRendering control options

References

define

Re-exports define


lazy

Re-exports lazy

Type Aliases

Type AliasDescription
ArgValuesAn object that contains the values of the arguments.
AwaitableAwaitable type.
CommandableDefine a command type.
CommandCallModeCommand call mode.
CommandContextCoreCommandContextCore type (base type without extensions)
CommandDecoratorCommand decorator. A function that wraps a command runner to add or modify its behavior.
CommandExamplesFetcherCommand examples fetcher.
CommandLoaderCommand loader. A function that returns a command or command runner. This is used to lazily load commands.
CommandRunnerCommand runner.
DefaultGunshiParamsDefault Gunshi parameters.
ExtendContextExtend command context type. This type is used to extend the command context with additional properties at CommandContext.extensions.
GunshiParamsConstraintGeneric constraint for command-related types.
LazyCommandLazy command interface. Lazy command that's not loaded until it is executed.
OnPluginExtensionPlugin extension callback, which is called when the plugin is extended with extension option.
PluginGunshi plugin, which is a function that receives a PluginContext.
PluginExtensionPlugin extension
PluginFunctionPlugin function type
RendererDecoratorRenderer decorator type. A function that wraps a base renderer to add or modify its behavior.
ValidationErrorsDecoratorValidation errors renderer decorator type. A function that wraps a validation errors renderer to add or modify its behavior.

Released under the MIT License.