-
Notifications
You must be signed in to change notification settings - Fork 0
/
flags.go
43 lines (37 loc) · 965 Bytes
/
flags.go
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
43
package main
import (
"flag"
"path/filepath"
log "github.com/sirupsen/logrus"
)
func parseFlags() (string, string) {
var yamlPath string
var envPath string
flag.StringVar(&yamlPath, "yaml", "", "path to yaml file")
flag.StringVar(&envPath, "env", "", "path to env file")
flag.Parse()
var absYamlPath string
var err error
if yamlPath != "" {
absYamlPath, err = filepath.Abs(yamlPath)
if err != nil {
logger.
WithFields(log.Fields{"error": err}).
Fatal("Could not get absolute path for yaml file")
panic(err)
}
logger.
WithFields(log.Fields{"yaml": absYamlPath}).
Debug("Found yaml file")
}
var absEnvPath string
if envPath != "" {
absEnvPath, err = filepath.Abs(envPath)
if err != nil {
logger.WithFields(log.Fields{"error": err}).Fatal("Could not get absolute path for env file")
panic(err)
}
logger.WithFields(log.Fields{"env": absEnvPath}).Debug("Found env file")
}
return absYamlPath, absEnvPath
}