[config] add config:export --format shell
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user