[config] add config:export --format shell

This commit is contained in:
Alex Quick
2017-07-16 19:50:50 -04:00
parent e7a81a8f8b
commit 4f5c747c99
3 changed files with 22 additions and 2 deletions

View File

@@ -17,7 +17,7 @@ func main() {
args := flag.NewFlagSet("config:export", flag.ExitOnError)
global := args.Bool("global", false, "--global: use the global environment")
merged := args.Bool("merged", false, "--merged: merge app environment and global environment")
format := args.String("format", "exports", "--format: [ exports | envfile | docker-args ] which format to export as)")
format := args.String("format", "exports", "--format: [ exports | envfile | docker-args | shell ] which format to export as)")
args.Parse(os.Args[2:])
appName, trailingArgs := config.GetCommonArgs(*global, args.Args())
@@ -27,6 +27,7 @@ func main() {
env := config.GetConfig(appName, *merged)
exportType := configenv.Exports
suffix := "\n"
switch *format {
case "exports":
exportType = configenv.Exports
@@ -34,9 +35,12 @@ func main() {
exportType = configenv.Envfile
case "docker-args":
exportType = configenv.DockerArgs
case "shell":
exportType = configenv.Shell
suffix = " "
default:
common.LogFail(fmt.Sprintf("Unknown export format: %v", *format))
}
exported := env.Export(exportType)
fmt.Println(exported)
fmt.Print(exported + suffix)
}