-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.go
More file actions
42 lines (34 loc) · 1.11 KB
/
main.go
File metadata and controls
42 lines (34 loc) · 1.11 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
package main
import (
"github.com/mediocregopher/flagconfig"
"fmt"
)
func main() {
//Create new flagconfig object
FC := flagconfig.New("flagconfigtest")
//Optionally set a description that'll show up in the command-line help
FC.SetDescription("A super cool test program")
//Specify the parameters we want to fetch
FC.StrParam("foo","Some foo","foofoofoo")
FC.IntParam("bar","Some bar",64)
FC.StrParams("baz","Some baz (can set multiple times)","a","b","c")
FC.FlagParam("bax", "Some bax", false)
FC.RequiredIntParam("baw","Some baw")
FC.IntParams("baq","Some baq (can set multiple times)",1,2,3)
//Optionally set a message to show up at the end of the --help message
FC.SetExtraHelp("Thanks for reading the --help message!")
//Parse command line and possibly config file
err := FC.Parse()
if err != nil {
fmt.Println(err.Error())
return
}
//Display the values that have been parsed
fmt.Println(FC.GetStr("foo"))
fmt.Println(FC.GetInt("bar"))
fmt.Println(FC.GetStrs("baz"))
fmt.Println(FC.GetFlag("bax"))
fmt.Println(FC.GetInt("baw"))
fmt.Println(FC.GetInts("baq"))
fmt.Println(FC.GetPositionals())
}