flen

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2020 License: MIT Imports: 4 Imported by: 6

README

flen

A simple command flag and environment variable parsing library

Example

$ cat > test.go <<EOF
package main

import (
        "flag"
        "fmt"

        "github.com/osm/flen"
)

func main() {
        name := flag.String("name", "foo", "A name")
        flen.SetEnvPrefix("TEST")
        flen.Parse()

        fmt.Println("hello", *name)
}
EOF

$ go run test.go
hello foo

$ TEST_NAME=bar go run test.go
hello bar

$ go run test.go -name baz
hello baz

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse() error

Parse parses the flags, command line arguments will be preferred over environment variables.

func SetEnvPrefix

func SetEnvPrefix(p string)

SetEnvPrefix sets the envPrefix variable.

Types

This section is empty.

Jump to

Keyboard shortcuts

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