cliflag

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2022 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package cliflag extends flagset with environment variable defaults.

Usage:

cliflag.String(root.Flags(), &address, "address", "a", "CODER_ADDRESS", "127.0.0.1:3000", "The address to serve the API and dashboard")

Will produce the following usage docs:

-a, --address string              The address to serve the API and dashboard (uses $CODER_ADDRESS). (default "127.0.0.1:3000")

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool added in v0.8.0

func Bool(flagset *pflag.FlagSet, name, shorthand, env string, def bool, usage string)

func BoolVarP

func BoolVarP(flagset *pflag.FlagSet, ptr *bool, name string, shorthand string, env string, def bool, usage string)

BoolVarP sets a bool flag on the given flag set.

func DurationVarP added in v0.6.0

func DurationVarP(flagset *pflag.FlagSet, ptr *time.Duration, name string, shorthand string, env string, def time.Duration, usage string)

DurationVarP sets a time.Duration flag on the given flag set.

func IntVarP added in v0.8.11

func IntVarP(flagset *pflag.FlagSet, ptr *int, name string, shorthand string, env string, def int, usage string)

IntVarP sets a uint8 flag on the given flag set.

func IsSet added in v0.8.0

func IsSet(cmd *cobra.Command, name string) (string, bool)

IsSet returns the string value of the flag and whether it was set.

func IsSetBool added in v0.8.0

func IsSetBool(cmd *cobra.Command, name string) bool

IsSetBool returns the value of the boolean flag if it is set. It returns false if the flag isn't set or if any error occurs attempting to parse the value of the flag.

func String added in v0.5.2

func String(flagset *pflag.FlagSet, name, shorthand, env, def, usage string)

String sets a string flag on the given flag set.

func StringArray added in v0.8.15

func StringArray(flagset *pflag.FlagSet, name, shorthand, env string, def []string, usage string)

func StringArrayVarP added in v0.4.4

func StringArrayVarP(flagset *pflag.FlagSet, ptr *[]string, name string, shorthand string, env string, def []string, usage string)

func StringVarP

func StringVarP(flagset *pflag.FlagSet, p *string, name string, shorthand string, env string, def string, usage string)

StringVarP sets a string flag on the given flag set.

func Uint8VarP

func Uint8VarP(flagset *pflag.FlagSet, ptr *uint8, name string, shorthand string, env string, def uint8, usage string)

Uint8VarP sets a uint8 flag on the given flag set.

Types

This section is empty.

Jump to

Keyboard shortcuts

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