flag

package
v0.3.35 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package flag implements flag-related functionality.

Index

Constants

View Source
const BuildpacksDockerHost = "buildpacks-docker-host"

BuildpacksDockerHost address to docker daemon that will be exposed to the buildpacks build container

View Source
const BuildpacksVolume = "buildpacks-volume"

BuildpacksVolume the host volume that will be mounted to the buildpacks build container

Variables

View Source
var VMSizeFlags = Set{
	String{
		Name:        "vm-size",
		Description: `The VM size to set machines to. See "fly platform vm-sizes" for valid values`,
	},
	Int{
		Name:        "vm-cpus",
		Description: "Number of CPUs",
		Aliases:     []string{"cpus"},
	},
	String{
		Name:        "vm-cpu-kind",
		Description: "The kind of CPU to use ('shared' or 'performance')",
		Aliases:     []string{"vm-cpukind"},
	},
	String{
		Name:        "vm-memory",
		Description: "Memory (in megabytes) to attribute to the VM",
		Aliases:     []string{"memory"},
	},
	Int{
		Name:        "vm-gpus",
		Description: "Number of GPUs. Must also choose the GPU model with --vm-gpu-kind flag",
	},
	String{
		Name:        "vm-gpu-kind",
		Description: fmt.Sprintf("If set, the GPU model to attach (%v)", strings.Join(validGPUKinds, ", ")),
		Aliases:     []string{"vm-gpukind"},
	},
	String{
		Name:        "host-dedication-id",
		Description: "The dedication id of the reserved hosts for your organization (if any)",
	},
}

Functions

func Add

func Add(cmd *cobra.Command, flags ...Flag)

Add adds flag to cmd, binding them on v should v not be nil.

func Args

func Args(ctx context.Context) []string

Args is shorthand for FromContext(ctx).Args().

func ExtraArgsFromContext added in v0.2.32

func ExtraArgsFromContext(ctx context.Context) []string

ExtraArgsFromContext returns the extraArgs ctx carries.

func FirstArg

func FirstArg(ctx context.Context) string

FirstArg returns the first arg ctx carries or an empty string in case ctx carries an empty argument set. It panics in case ctx carries no FlagSet.

func FromContext

func FromContext(ctx context.Context) *pflag.FlagSet

FromContext returns the FlagSet ctx carries. It panics in case ctx carries no FlagSet.

func GetApp

func GetApp(ctx context.Context) string

GetApp is shorthand for GetString(ctx, App).

func GetAppConfigFilePath

func GetAppConfigFilePath(ctx context.Context) string

GetAppConfigFilePath is shorthand for GetString(ctx, AppConfigFilePath).

func GetBindAddr added in v0.1.59

func GetBindAddr(ctx context.Context) string

GetBindAddr is shorthand for GetString(ctx, BindAddr).

func GetBool

func GetBool(ctx context.Context, name string) bool

GetBool returns the value of the named boolean flag ctx carries.

func GetBuildOnly

func GetBuildOnly(ctx context.Context) bool

func GetDetach

func GetDetach(ctx context.Context) bool

func GetDuration added in v0.0.500

func GetDuration(ctx context.Context, name string) time.Duration

GetDuration returns the value of the named duration flag ctx carries.

func GetFlagsName added in v0.1.1

func GetFlagsName(ctx context.Context, ignoreFlags []string) []string

GetFlagsName returns the name of flags that have been set except unwanted flags.

func GetFloat64 added in v0.1.75

func GetFloat64(ctx context.Context, name string) float64

GetFloat64 returns the value of the named int flag ctx carries. It panics in case ctx carries no flags or in case the named flag isn't a float64 one.

func GetHTTPSFailover added in v0.2.55

func GetHTTPSFailover(ctx context.Context) bool

func GetInt

func GetInt(ctx context.Context, name string) int

GetInt returns the value of the named int flag ctx carries. It panics in case ctx carries no flags or in case the named flag isn't an int one.

func GetLocalOnly

func GetLocalOnly(ctx context.Context) bool

func GetMachineGuest added in v0.1.86

func GetMachineGuest(ctx context.Context, guest *fly.MachineGuest) (*fly.MachineGuest, error)

Returns a MachineGuest based on the flags provided overwriting a default VM

func GetNonEmptyStringSlice added in v0.2.50

func GetNonEmptyStringSlice(ctx context.Context, name string) []string

GetStringSlice returns the values of the named string flag ctx carries. Can be comma separated or passed "by repeated flags": `--flag x,y` is equivalent to `--flag x --flag y`. Strings are trimmed of extra whitespace and empty strings are removed.

func GetOrg

func GetOrg(ctx context.Context) string

GetOrg is shorthand for GetString(ctx, Org).

func GetProcessGroup added in v0.1.86

func GetProcessGroup(ctx context.Context) string

func GetRecreateBuilder added in v0.2.71

func GetRecreateBuilder(ctx context.Context) bool

func GetRegion

func GetRegion(ctx context.Context) string

GetRegion is shorthand for GetString(ctx, Region).

func GetRemoteOnly

func GetRemoteOnly(ctx context.Context) bool

func GetString

func GetString(ctx context.Context, name string) string

GetString returns the value of the named string flag ctx carries.

func GetStringArray added in v0.1.1

func GetStringArray(ctx context.Context, name string) []string

GetStringArray returns the values of the named string flag ctx carries. Preserves commas (unlike the following `GetStringSlice`): in `--flag x,y` the value is string[]{`x,y`}. This is useful to pass key-value pairs like environment variables or build arguments.

func GetStringSlice

func GetStringSlice(ctx context.Context, name string) []string

GetStringSlice returns the values of the named string flag ctx carries. Can be comma separated or passed "by repeated flags": `--flag x,y` is equivalent to `--flag x --flag y`.

func GetWireguard added in v0.2.12

func GetWireguard(ctx context.Context) bool

func GetYes

func GetYes(ctx context.Context) bool

GetYes is shorthand for GetBool(ctx, Yes).

func IsSpecified added in v0.0.475

func IsSpecified(ctx context.Context, name string) bool

IsSpecified returns whether a flag has been specified at all or not. This is useful, for example, when differentiating between 0/"" and unspecified.

func NewContext

func NewContext(ctx context.Context, fs *pflag.FlagSet) context.Context

NewContext derives a context that carries fs from ctx.

func SetString added in v0.0.530

func SetString(ctx context.Context, name, value string) error

SetString sets the value of the named string flag ctx carries.

func WithExtraArgs added in v0.2.32

func WithExtraArgs(ctx context.Context, extraArgs []string) context.Context

WithExtraArgs derives a context that carries extraArgs from ctx.

Types

type Bool

type Bool struct {
	Name        string
	Shorthand   string
	Description string
	Default     bool
	Hidden      bool
	Aliases     []string
}

Bool wraps the set of boolean flags.

func BuildOnly

func BuildOnly() Bool

BuildOnly returns a boolean flag for building without a deployment

func Detach

func Detach() Bool

Detach returns a boolean flag for detaching during deployment

func GenerateName

func GenerateName() Bool

GenerateName returns a boolean flag for generating an application name

func HttpsFailover added in v0.2.55

func HttpsFailover() Bool

func JSONOutput added in v0.0.519

func JSONOutput() Bool

func LocalOnly

func LocalOnly() Bool

RemoteOnly returns a boolean flag for deploying remotely

func Nixpacks added in v0.0.362

func Nixpacks() Bool

func NoCache added in v0.0.337

func NoCache() Bool

func NoDeploy added in v0.0.452

func NoDeploy() Bool

func Now

func Now() Bool

Now returns a boolean flag for deploying immediately

func Push added in v0.0.311

func Push() Bool

Push returns a boolean flag to force pushing a build image to the registry

func RecreateBuilder added in v0.2.71

func RecreateBuilder() Bool

func RemoteOnly

func RemoteOnly(defaultValue bool) Bool

RemoteOnly returns a boolean flag for deploying remotely

func Wireguard added in v0.2.12

func Wireguard() Bool

Wireguard returns a boolean flag indicating whether to build over wireguard or not

func Yes

func Yes() Bool

Yes returns a yes bool flag.

type Duration added in v0.0.500

type Duration struct {
	Name        string
	Shorthand   string
	Description string
	Default     time.Duration
	ConfName    string
	EnvName     string
	Hidden      bool
	Aliases     []string
}

Duration wraps the set of duration flags.

type Flag

type Flag interface {
	// contains filtered or unexported methods
}

Flag wraps the set of flags.

type Float64 added in v0.1.75

type Float64 struct {
	Name        string
	Shorthand   string
	Description string
	Default     float64
	Hidden      bool
	Aliases     []string
}

Int wraps the set of int flags.

type Int

type Int struct {
	Name        string
	Shorthand   string
	Description string
	Default     int
	Hidden      bool
	Aliases     []string
}

Int wraps the set of int flags.

type Set added in v0.0.361

type Set []Flag

type String

type String struct {
	Name              string
	Shorthand         string
	Description       string
	Default           string
	NoOptDefVal       string
	ConfName          string
	EnvName           string
	Hidden            bool
	Aliases           []string
	UseAliasShortHand bool
	CompletionFn      func(ctx context.Context, cmd *cobra.Command, args []string, partial string) ([]string, error)
}

String wraps the set of string flags.

func App

func App() String

App returns an app string flag.

func AppConfig

func AppConfig() String

AppConfig returns an app config string flag.

func BpDockerHost added in v0.1.135

func BpDockerHost() String

func BuildTarget added in v0.0.337

func BuildTarget() String

func Depot added in v0.2.101

func Depot() String

func DepotScope added in v0.2.118

func DepotScope() String

func Dockerfile added in v0.0.335

func Dockerfile() String

func Ignorefile added in v0.0.433

func Ignorefile() String

func Image

func Image() String

Image returns a Docker image config string flag.

func ImageLabel added in v0.0.337

func ImageLabel() String

func Org

func Org() String

Org returns an org string flag.

func ProcessGroup added in v0.1.86

func ProcessGroup(desc string) String

func Region

func Region() String

Region returns a region string flag.

func ReplicaRegions added in v0.1.70

func ReplicaRegions() String

func Strategy added in v0.0.362

func Strategy() String

type StringArray added in v0.1.1

type StringArray struct {
	Name        string
	Shorthand   string
	Description string
	Default     []string
	ConfName    string
	EnvName     string
	Hidden      bool
	Aliases     []string
}

StringArray wraps the set of string array flags.

func BuildArg added in v0.0.337

func BuildArg() StringArray

func BuildSecret added in v0.0.337

func BuildSecret() StringArray

func Env added in v0.2.123

func Env() StringArray

type StringSlice

type StringSlice struct {
	Name        string
	Shorthand   string
	Description string
	Default     []string
	ConfName    string
	EnvName     string
	Hidden      bool
	Aliases     []string
}

StringSlice wraps the set of string slice flags.

func BpVolume added in v0.1.135

func BpVolume() StringSlice

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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