goflags

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2021 License: MIT Imports: 14 Imported by: 494

README

goflags

A wrapper on go flag library adding some convenience wrappers like better Usage, short and long flags, config file support, etc.

Thanks
  1. spf13/cobra - The very nice usage template for the command line.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FlagSet

type FlagSet struct {
	Marshal bool
	// contains filtered or unexported fields
}

FlagSet is a list of flags for an application

func New

func New() *FlagSet

New creates a new flagset structure for the application

func (*FlagSet) BoolVar

func (f *FlagSet) BoolVar(field *bool, long string, defaultValue bool, usage string)

BoolVar adds a bool flag with a longname

func (*FlagSet) BoolVarP

func (f *FlagSet) BoolVarP(field *bool, long, short string, defaultValue bool, usage string)

BoolVarP adds a bool flag with a shortname and longname

func (*FlagSet) IntVar

func (f *FlagSet) IntVar(field *int, long string, defaultValue int, usage string)

IntVar adds a int flag with a longname

func (*FlagSet) IntVarP

func (f *FlagSet) IntVarP(field *int, long, short string, defaultValue int, usage string)

IntVarP adds a int flag with a shortname and longname

func (*FlagSet) MergeConfigFile

func (f *FlagSet) MergeConfigFile(file string) error

MergeConfigFile reads a config file to merge values from.

func (*FlagSet) Parse

func (f *FlagSet) Parse() error

Parse parses the flags provided to the library.

func (*FlagSet) SetDescription

func (f *FlagSet) SetDescription(description string)

SetDescription sets the description field for a flagset to a value.

func (*FlagSet) StringSliceVar

func (f *FlagSet) StringSliceVar(field *StringSlice, long string, defaultValue []string, usage string)

StringSliceVar adds a string slice flag with a longname

func (*FlagSet) StringSliceVarP

func (f *FlagSet) StringSliceVarP(field *StringSlice, long, short string, defaultValue []string, usage string)

StringSliceVarP adds a string slice flag with a shortname and longname

func (*FlagSet) StringVar

func (f *FlagSet) StringVar(field *string, long, defaultValue, usage string)

StringVar adds a string flag with a longname

func (*FlagSet) StringVarEnv added in v0.0.3

func (f *FlagSet) StringVarEnv(field *string, long, short, defaultValue, envName, usage string)

StringVarEnv adds a string flag with a shortname and longname with a default value read from env variable with a default value fallback

func (*FlagSet) StringVarP

func (f *FlagSet) StringVarP(field *string, long, short, defaultValue, usage string)

StringVarP adds a string flag with a shortname and longname

func (*FlagSet) Var added in v0.0.3

func (f *FlagSet) Var(field flag.Value, long, usage string)

Var adds a Var flag with a longname

func (*FlagSet) VarP added in v0.0.3

func (f *FlagSet) VarP(field flag.Value, long, short, usage string)

VarP adds a Var flag with a shortname and longname

type StringSlice

type StringSlice []string

StringSlice is a slice of strings

func (*StringSlice) Set

func (i *StringSlice) Set(value string) error

Set appends a value to the string slice.

func (*StringSlice) String

func (i *StringSlice) String() string

Jump to

Keyboard shortcuts

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