Skip to content

Commit

Permalink
Make shuttle get output yaml instead of go
Browse files Browse the repository at this point in the history
  • Loading branch information
emilingerslev committed Oct 11, 2018
1 parent c20e4dc commit c5c8e31
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion cmd/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ package cmd

import (
"fmt"
"strings"

"gopkg.in/yaml.v2"

"github.com/lunarway/shuttle/pkg/templates"
"github.com/lunarway/shuttle/pkg/ui"
Expand All @@ -20,7 +23,17 @@ var getCmd = &cobra.Command{
uii = uii.SetContext(ui.LevelSilent)
context := getProjectContext()
path := args[0]
fmt.Print(templates.TmplGet(path, context.Config.Variables))
value := templates.TmplGet(path, context.Config.Variables)
switch value.(type) {
case nil:
// print nothing
default:
x, err := yaml.Marshal(value)
if err != nil {
uii.ExitWithErrorCode(9, "Could not yaml encoded %s\nError: %s", value, err)
}
fmt.Print(strings.TrimRight(string(x), "\n"))
}
},
}

Expand Down

0 comments on commit c5c8e31

Please sign in to comment.