serpent

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 18, 2023 License: MIT Imports: 5 Imported by: 3

Documentation

Overview

Package serpent provides a way to combine the shaft framework with github.com/spf13/cobra nicely, providing a dependency injection style monolithc CLI interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddOption

func AddOption(cmd *cobra.Command, options ...core.Option) error

AddOption attempts add options to the current command.

func Execute

func Execute(cmd *cobra.Command, options ...core.Option) error

Execute sets up the command context and invoke the specified functions.

func ExecuteContext

func ExecuteContext(
	ctx context.Context, cmd *cobra.Command, options ...core.Option,
) error

ExecuteContext sets up the command context and invoke the specified function.

Types

type CommandArgs

type CommandArgs []string

CommandArgs is the arguments passed in the command.

type CommandContext

type CommandContext context.Context

CommandContext is the context of the executed command.

type CommandObject

type CommandObject *cobra.Command

CommandObject is the command object that is executed.

type Executor

type Executor core.Option

Executor is the executor for this command. We usually attach the executor's corresponding methods to cobra.Command's RunE or PreRunE field.

When PreRunE is attached, the command provides dependencies specified in the executor to subcommands under its directory. Actually the execution is not based on the cobra's, and we require the user to ensure at least the path from the executed command to the root command is managed by the serpent.

When RunE is attached, the command collects all previously provided options up to this node and execute them.

func (Executor) PreRunE

func (e Executor) PreRunE(cmd *cobra.Command, args []string) error

func (Executor) RunE

func (e Executor) RunE(cmd *cobra.Command, args []string) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL