commands

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddBoolFlag

func AddBoolFlag(cmd *Command, name, shorthand string, def bool, desc string, opts ...flagOpt)

AddBoolFlag adds a boolean flag to a command.

func AddStringFlag

func AddStringFlag(cmd *Command, name, shorthand, dflt, desc string, opts ...flagOpt)

AddStringFlag adds a string flag to a command.

func AddStringSliceFlag

func AddStringSliceFlag(cmd *Command, name, shorthand string, def []string, desc string, opts ...flagOpt)

AddStringSliceFlag adds a string slice flag to a command.

func Execute

func Execute()

Execute executes the current command using rootCmd.

Types

type CmdConfig

type CmdConfig struct {
	NS   string
	Out  io.Writer
	Args []string

	// Services
	Categories    func() client.CategoriesService
	Letters       func() client.LettersService
	Organizations func() client.OrganizationsService
	Products      func() client.ProductsService
	// contains filtered or unexported fields
}

CmdConfig is a command configuration.

func NewCmdConfig

func NewCmdConfig(ns string, out io.Writer, args []string, initServices bool) (*CmdConfig, error)

NewCmdConfig creates an instance of a CmdConfig.

func (*CmdConfig) Display

func (c *CmdConfig) Display(d displayers.Displayable) error

Display displays the output from a command.

type CmdRunner

type CmdRunner func(*CmdConfig) error

CmdRunner runs a command and passes in a cmdConfig.

type Command

type Command struct {
	*cobra.Command
	// contains filtered or unexported fields
}

Command is a wrapper around cobra.Command that adds gocancel specific functionality.

func CmdBuilder

func CmdBuilder(parent *Command, cr CmdRunner, cliText, shortdesc string, longdesc string, out io.Writer, options ...cmdOption) *Command

func (*Command) AddCommand

func (c *Command) AddCommand(commands ...*Command)

AddCommand adds child commands and adds child commands for cobra as well.

type LetterPayload

type LetterPayload struct {
	*gocancel.LetterRequest
}

type MissingArgsErr

type MissingArgsErr struct {
	Command string
}

MissingArgsErr is returned when there are too few arguments for a command.

func NewMissingArgsErr

func NewMissingArgsErr(cmd string) *MissingArgsErr

NewMissingArgsErr creates a MissingArgsErr instance.

func (*MissingArgsErr) Error

func (e *MissingArgsErr) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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