diff --git a/cmd/dagger/cmd/common/common.go b/cmd/dagger/cmd/common/common.go index d2c041fb..a83560e8 100644 --- a/cmd/dagger/cmd/common/common.go +++ b/cmd/dagger/cmd/common/common.go @@ -2,6 +2,7 @@ package common import ( "context" + "fmt" "strings" "github.com/rs/zerolog/log" @@ -100,15 +101,21 @@ func EnvironmentUp(ctx context.Context, state *state.State, noCache bool) *envir return result } -// ValueType returns the String representation of the cue value -func ValueType(val *compiler.Value) string { +// FormatValue returns the String representation of the cue value +func FormatValue(val *compiler.Value) string { if val.HasAttr("artifact") { return "dagger.#Artifact" } if val.HasAttr("secret") { return "dagger.#Secret" } - return val.Cue().IncompleteKind().String() + if val.IsConcreteR() != nil { + return val.Cue().IncompleteKind().String() + } + // value representation in Cue + valStr := fmt.Sprintf("%v", val.Cue()) + // escape \n + return strings.ReplaceAll(valStr, "\n", "\\n") } // ValueDocString returns the value doc from the comment lines diff --git a/cmd/dagger/cmd/input/list.go b/cmd/dagger/cmd/input/list.go index 4135085b..a4c8130d 100644 --- a/cmd/dagger/cmd/input/list.go +++ b/cmd/dagger/cmd/input/list.go @@ -4,7 +4,6 @@ import ( "context" "fmt" "os" - "strings" "text/tabwriter" "go.dagger.io/dagger/client" @@ -53,20 +52,20 @@ var listCmd = &cobra.Command{ } w := tabwriter.NewWriter(os.Stdout, 0, 4, 2, ' ', 0) - fmt.Fprintln(w, "Input\tType\tValue\tSet by user\tDescription") + fmt.Fprintln(w, "Input\tValue\tSet by user\tDescription") for _, inp := range inputs { isConcrete := (inp.IsConcreteR() == nil) _, hasDefault := inp.Default() - valStr := "-" - if isConcrete { - valStr, _ = inp.Cue().String() - } - if hasDefault { - valStr = fmt.Sprintf("%s (default)", valStr) - } + // valStr := "-" + // if isConcrete { + // valStr, _ = inp.Cue().String() + // } + // if hasDefault { + // valStr = fmt.Sprintf("%s (default)", valStr) + // } - valStr = strings.ReplaceAll(valStr, "\n", "\\n") + // valStr = strings.ReplaceAll(valStr, "\n", "\\n") if !viper.GetBool("all") { // skip input that is not overridable @@ -75,10 +74,9 @@ var listCmd = &cobra.Command{ } } - fmt.Fprintf(w, "%s\t%s\t%s\t%t\t%s\n", + fmt.Fprintf(w, "%s\t%s\t%t\t%s\n", inp.Path(), - common.ValueType(inp), - valStr, + common.FormatValue(inp), isUserSet(st, inp), common.ValueDocString(inp), )