kong-hcl – github.com/alecthomas/kong-hcl Index | Files

package konghcl

import "github.com/alecthomas/kong-hcl"

Index

Functions

func Loader

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

Loader is a Kong configuration loader for HCL.

Types

type RawConfigFlag

type RawConfigFlag map[string]interface{}

RawConfigFlag is a Kong flag value that can be used to load HCL config either from an external file or from fragments embedded in the main configuration file.

Use it like so:

var cli struct {
	Fragment RawConfigFlag
}
// parsing...

// Once flags are parsed, unmarshal HCL fragment into an object.
if cli.Fragment != nil {
	err = cli.Fragment.UnmarshalHCL(&obj)
}

func (*RawConfigFlag) Decode

func (r *RawConfigFlag) Decode(ctx *kong.DecodeContext) error

Decode file or fragment into value.

func (*RawConfigFlag) UnmarshalHCL

func (r *RawConfigFlag) UnmarshalHCL(v interface{}) error

UnmarshalHCL unmarshals the flag into a Go value.

type Resolver

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

Resolver resolves kong Flags from configuration in HCL.

func (*Resolver) Resolve

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

func (*Resolver) Validate

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

Source Files

loader.go raw.go

Version
v0.1.6
Published
Nov 6, 2018
Platform
js/wasm
Imports
7 packages
Last checked
now

Tools for package owners.