util

package
v0.0.0-...-9dcd13a Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2017 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ProgramInfo struct {
	Name        string
	Description string
}

Functions

func Argv

func Argv(key string) string

Argv fetches command line argument by its name. Usable only after ParseArgv is completed.

func Blame

func Blame(format string, args ...interface{})

Blame prints message to stderr using fmt.Fprintf and then exits with non-zero status code.

func CheckError

func CheckError(err error)

CheckError will invoke Blame if error is not nil.

func ParseArgv

func ParseArgv(schema ArgvSchema)

ParseArgv parses command line arguments using specified schema. Argument values can be accessed via Argv function.

func Usage

func Usage()

Usage prints usage text and exits with code 0.

Types

type ArgTemplate

type ArgTemplate struct {
	// If set to true, error if raised when argument is not
	// set explicitly.
	Req bool
	// If set to true, Help string is parsed for {[\w\|]*} pattern.
	// Value is checked against that pattern.
	Enum bool
	// Default value.
	Init string
	// Argument description.
	Help string
}

ArgTemplate describes command line argument.

type ArgvSchema

type ArgvSchema map[string]ArgTemplate

ArgvSchema is a set of command line arguments accepted by application.

Jump to

Keyboard shortcuts

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