[config] preliminary Dockerfile support

This commit is contained in:
Alex Quick
2017-01-30 22:20:39 -05:00
parent dfa241d6a9
commit 73e85b7df5
10 changed files with 79 additions and 24 deletions

View File

@@ -13,6 +13,7 @@ import (
func main() {
args := flag.NewFlagSet("config:export", flag.ExitOnError)
global := args.Bool("global", false, "--global: use the global environment")
keys := args.Bool("keys", false, "--keys: export keys only")
envfile := args.Bool("envfile", false, "--envfile: export as envfile rather than bash exports")
args.Parse(os.Args[2:])
@@ -32,6 +33,13 @@ func main() {
if err != nil {
common.LogFail(err.Error())
}
if *keys {
for _, k := range env.Keys() {
fmt.Println(k)
}
return
}
if *envfile {
fmt.Println(env.EnvfileString())
} else {

View File

@@ -13,6 +13,7 @@ import (
func main() {
args := flag.NewFlagSet("config:get", flag.ExitOnError)
global := args.Bool("global", false, "--global: use the global environment")
quoted := args.Bool("quoted", false, "--quoted: get the value quoted")
args.Parse(os.Args[2:])
appName := args.Arg(0)
nextArg := 0
@@ -35,5 +36,10 @@ func main() {
common.LogFail(fmt.Sprintf("Unexpected argument(s): %v", args.Args()[nextArg+1:]))
}
key := args.Arg(nextArg)
fmt.Printf("%s", env.GetDefault(key, ""))
value := env.GetDefault(key, "")
if *quoted {
fmt.Printf("'%s'", configenv.SingleQuoteEscape(value))
} else {
fmt.Printf("%s", value)
}
}