-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathflags.go
More file actions
29 lines (23 loc) Β· 770 Bytes
/
flags.go
File metadata and controls
29 lines (23 loc) Β· 770 Bytes
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 copper
import (
"flag"
"github.com/gocopper/copper/cconfig"
)
// Flags holds flag values passed in via command line. These can be used to configure the app environment
// and override the config directory.
type Flags struct {
ConfigPath cconfig.Path
ConfigOverrides cconfig.Overrides
}
// NewFlags reads the command line flags and returns Flags with the values set.
func NewFlags() *Flags {
var (
configPath = flag.String("config", "./config/dev.toml", "Path to config file")
configOverrides = flag.String("set", "", "Config overrides ex. \"chttp.port=5902\". Separate multiple overrides with ;")
)
flag.Parse()
return &Flags{
ConfigPath: cconfig.Path(*configPath),
ConfigOverrides: cconfig.Overrides(*configOverrides),
}
}