cmd

package module
v0.0.0-...-8a10f5f Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: MPL-2.0 Imports: 12 Imported by: 13

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// RootCmd is the base command (what the binary is called)
	RootCmd = &cobra.Command{
		Use:   "bat-go",
		Short: "bat-go provides go based services and processes for BAT",
	}
)
View Source
var VersionCmd = &cobra.Command{
	Use:   "version",
	Short: "get the version of this binary",
	Run:   versionRun,
}

VersionCmd is the command to get the code's version information

Functions

func Execute

func Execute(version, commit, buildTime string)

Execute - the main entrypoint for all subcommands in bat-go

func Must

func Must(err error)

Must helper to make sure there is no errors

func Perform

func Perform(action string, fn func(cmd *cobra.Command, args []string) error) func(cmd *cobra.Command, args []string)

Perform performs a run

Types

type FlagBuilder

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

FlagBuilder creates a flag builder

func NewFlagBuilder

func NewFlagBuilder(command *cobra.Command) *FlagBuilder

NewFlagBuilder creates a new FlagBuilder from one command

func (*FlagBuilder) AddCommand

func (fb *FlagBuilder) AddCommand(command *cobra.Command) *FlagBuilder

AddCommand adds a command

func (*FlagBuilder) Bind

func (fb *FlagBuilder) Bind(key string) *FlagBuilder

Bind runs the BindPFlag function

func (*FlagBuilder) Bool

func (fb *FlagBuilder) Bool(key string, defaultValue bool, description string) *FlagBuilder

Bool attaches a bool flag to the command

func (*FlagBuilder) BoolP

func (fb *FlagBuilder) BoolP(key string, shortKey string, defaultValue bool, description string) *FlagBuilder

BoolP attaches a boolean flag to the command

func (*FlagBuilder) Concat

func (fb *FlagBuilder) Concat(builders ...*FlagBuilder) *FlagBuilder

Concat combine flag builders

func (*FlagBuilder) Duration

func (fb *FlagBuilder) Duration(key string, defaultValue time.Duration, description string) *FlagBuilder

Duration attaches a string flag to the command

func (*FlagBuilder) Env

func (fb *FlagBuilder) Env(env string) *FlagBuilder

Env attaches an env

func (*FlagBuilder) Flag

func (fb *FlagBuilder) Flag() *FlagBuilder

Flag resets the builder to allow for chaining

func (*FlagBuilder) Float64

func (fb *FlagBuilder) Float64(key string, defaultValue float64, description string) *FlagBuilder

Float64 attaches a float64 type flag to the command

func (*FlagBuilder) Int

func (fb *FlagBuilder) Int(key string, defaultValue int, description string) *FlagBuilder

Int attaches an int flag to the command

func (*FlagBuilder) Require

func (fb *FlagBuilder) Require() *FlagBuilder

Require requires the flag

func (*FlagBuilder) SetKey

func (fb *FlagBuilder) SetKey(key string) *FlagBuilder

SetKey sets the key to be shared across methods

func (*FlagBuilder) String

func (fb *FlagBuilder) String(key string, defaultValue string, description string) *FlagBuilder

String attaches a string flag to the command

func (*FlagBuilder) StringSlice

func (fb *FlagBuilder) StringSlice(key string, defaultValue []string, description string) *FlagBuilder

StringSlice attaches a string slice flag to the command

func (*FlagBuilder) Uint

func (fb *FlagBuilder) Uint(key string, defaultValue uint, description string) *FlagBuilder

Uint attaches an uint flag to the command

Jump to

Keyboard shortcuts

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