cliflag

package
v0.0.0-...-0f74808 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: AGPL-3.0 Imports: 7 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

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

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

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

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

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

func IsSetBool

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

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

String sets a string flag on the given flag set.

func StringArray

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

func StringArrayVarP

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