aboutsummaryrefslogtreecommitdiff
path: root/example_test.go
blob: 349a36b703bce127a675ad5b6e8ba2e1f2430191 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package envflag_test

import (
	"flag"
	"os"

	"userspace.com.au/envflag"
)

func ExampleFlag() {
	flag.Bool("verbose", false, "Be verbose")
	envflag.Parse()
}

func ExampleFlagSet() {
	fs := flag.NewFlagSet("example", flag.ExitOnError)
	fs.Bool("verbose", false, "Be verbose")
	_ = envflag.ParseFlagSet(fs, os.Args[1:], envflag.UsageSuffixer())
}

func ExamplePrefix() {
	flag.String("db", "", "Database thing")
	_ = envflag.Parse(envflag.Prefix("APP_"))
}

func ExampleUsageSuffixer() {
	flag.String("db", "", "Database thing")
	_ = envflag.Parse(envflag.Prefix("APP_"))
}