clicobra

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2019 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package clicobra contains helper functionality for applications using Cobra.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Main

func Main(rootCommand *Command, version string)

Main runs the application using the OS runtime and calling os.Exit on the return value of Run.

func Run

func Run(rootCommand *Command, version string, runEnv *cli.RunEnv) int

Run runs the application, returning the exit code.

RunEnv will be modified to have dummy values if fields are not set.

Types

type Command

type Command struct {
	// Use is the one-line usage message. Required.
	Use string
	// Short is the short message shown in the 'help' output. Required if Long is set.
	Short string
	// Long is the long message shown in the 'help <this-command>' output. Optional.
	// The Short field will be prepended to the Long field with a newline.
	Long string
	// Args are the expected arguments. Optional.
	Args cobra.PositionalArgs
	// Run is the command to run. Optional.
	Run func(*cli.ExecEnv) error
	// BindFlags allows binding of flags on build. Optional.
	BindFlags func(*pflag.FlagSet)
	// SubCommands are the sub-commands. Optional.
	SubCommands []*Command
}

Command is a command.

type Flags

type Flags struct {
	// contains filtered or unexported fields
}

Flags are base flags.

func NewFlags

func NewFlags(devel bool) *Flags

NewFlags returns a new Flags.

Devel should not be set for release binaries.

func (*Flags) BindRootCommandFlags added in v0.2.0

func (f *Flags) BindRootCommandFlags(flagSet *pflag.FlagSet)

BindRootCommandFlags binds the root-command flags.

func (*Flags) Devel

func (f *Flags) Devel() bool

Devel returns true if devel was set.

func (*Flags) NewRunFunc added in v0.2.0

func (f *Flags) NewRunFunc(
	fn func(
		*cli.ExecEnv,
		*zap.Logger,
		*bytepool.SegList,
	) error,
) func(*cli.ExecEnv) error

NewRunFunc creates a new run function.

type TimeoutFlags added in v0.2.0

type TimeoutFlags struct {
	// contains filtered or unexported fields
}

TimeoutFlags are base flags with a root timeout.

func NewTimeoutFlags added in v0.2.0

func NewTimeoutFlags(devel bool) *TimeoutFlags

NewTimeoutFlags returns a new TimeoutFlags.

Devel should not be set for release binaries.

func (*TimeoutFlags) BindRootCommandFlags added in v0.2.0

func (t *TimeoutFlags) BindRootCommandFlags(flagSet *pflag.FlagSet, defaultTimeout time.Duration)

BindRootCommandFlags binds the root-command flags with timeout.

func (*TimeoutFlags) Devel added in v0.2.0

func (t *TimeoutFlags) Devel() bool

Devel returns true if devel was set.

func (*TimeoutFlags) NewRunFunc added in v0.2.0

func (t *TimeoutFlags) NewRunFunc(
	fn func(
		context.Context,
		*cli.ExecEnv,
		*zap.Logger,
		*bytepool.SegList,
	) error,
) func(*cli.ExecEnv) error

NewRunFunc creates a new run function.

Jump to

Keyboard shortcuts

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