globalconf: Index | Files

package globalconf

import ""


Package Files


func Register Uses

func Register(flagSetName string, set *flag.FlagSet, errorHandling flag.ErrorHandling)

Register registers a flag set to be parsed. Register all flag sets before calling this function. flag.CommandLine is automatically registered.

type GlobalConf Uses

type GlobalConf struct {
    Filename  string
    EnvPrefix string
    // contains filtered or unexported fields

Represents a GlobalConf context.

func New Uses

func New(appName string) (g *GlobalConf, err error)

Opens/creates a config file for the specified appName. The path to config file is ~/.config/appName/config.ini.

func NewWithOptions Uses

func NewWithOptions(opts *Options) (g *GlobalConf, err error)

NewWithOptions creates a GlobalConf from the provided Options. The caller is responsible for creating any referenced config files.

func (*GlobalConf) Delete Uses

func (g *GlobalConf) Delete(flagSetName, flagName string) error

Deletes a flag from config file and persists the changes to the disk.

func (*GlobalConf) Parse Uses

func (g *GlobalConf) Parse()

Parse parses all the registered flag sets, including the command line set and sets values from the config file if they are not already set.

func (*GlobalConf) ParseAll Uses

func (g *GlobalConf) ParseAll()

Parses command line flags and then, all of the registered flag sets with the values provided in the config file.

func (*GlobalConf) ParseSet Uses

func (g *GlobalConf) ParseSet(flagSetName string, set *flag.FlagSet)

ParseSet parses the config file for the provided flag set. If the flags are already set, values are overwritten by the values in the config file. Defaults are not set if the flag is not in the file.

func (*GlobalConf) Set Uses

func (g *GlobalConf) Set(flagSetName string, f *flag.Flag) error

Sets a flag's value and persists the changes to the disk.

type Options Uses

type Options struct {
    Filename  string
    EnvPrefix string

Package globalconf imports 8 packages (graph) and is imported by 42 packages. Updated 2019-01-30. Refresh now. Tools for package owners.