Categorygithub.com/osm/flen
modulepackage
1.0.0
Repository: https://github.com/osm/flen.git
Documentation: pkg.go.dev

# 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

# Functions

Parse parses the flags, command line arguments will be preferred over environment variables.
SetEnvPrefix sets the envPrefix variable.