kongini

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2020 License: MIT Imports: 6 Imported by: 0

README

kong-ini

A kong configuration resolver for .ini files.

Usage

var cli struct {
    Config kong.ConfigFlag `help:"Load configuration."`
}
parser, err := kong.New(&cli, kong.Configuration(kongini.Loader, "/etc/myapp/config.ini", "~/.myapp.ini))
Config Format

Given the following app definition:

var cli struct {
	Config     kong.ConfigFlag `help:"Load configuration."`
	Debug      bool            `kong:"name='debug'"`
	String     string          `kong:"name='string'"`
	Int        int             `kong:"name='int'"`
	Slice      []string        `kong:"name='slice'"`
	Intslice   []int           `kong:"name='intslice'"`
	Floatslice []float64       `kong:"name='floatslice'"`
	Map        map[string]int  `kong:"name='map'"`
	Command    struct {
		IsFoo bool   `kong:"name='isFoo'"`
		Value string `kong:"name='value'"`
	} `kong:"cmd"`
	Default struct {
	} `kong:"cmd"`
}

This would be the corresponding .ini file:

debug = true
string = "a string"
int = 1
slice = bla,foo bar,test
intslice = 1,2,3
floatslice = 1.2,2.3,3.4
map = """a=1;b=2;c=3"""

[command]
isFoo = false
value = bar

Installation

go get github.com/mrtazz/kong-ini

Inspiration

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Loader

func Loader(r io.Reader) (kong.Resolver, error)

Loader is a Kong configuration loader for HCL.

Types

type Resolver

type Resolver struct {
	// contains filtered or unexported fields
}

Resolver is the receiver for the interface methods

func (*Resolver) Resolve

func (r *Resolver) Resolve(context *kong.Context, parent *kong.Path, flag *kong.Flag) (interface{}, error)

Resolve implements the kong Resolver interface

func (*Resolver) Validate

func (r *Resolver) Validate(app *kong.Application) error

Validate implements the kong Resolver interface

Jump to

Keyboard shortcuts

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