clicobra

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2020 License: Apache-2.0 Imports: 8 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, env clienv.Env) int

Run runs the application, returning the exit code.

Env 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.
	// The Short field will be prepended to the Long field with a newline.
	// Must be unset if short is unset.
	Long string
	// Args are the expected arguments.
	Args cobra.PositionalArgs
	// BindFlags allows binding of flags on build.
	BindFlags func(*pflag.FlagSet)
	// Run is the command to run.
	// Required if there are no sub-commands.
	// Must be unset if there are sub-commands.
	Run func(clienv.Env) error
	// SubCommands are the sub-commands. Optional.
	// Must be unset if there is a run function.
	SubCommands []*Command
}

Command is a command.

Jump to

Keyboard shortcuts

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