compiler.Value abstraction for docstring and incompletekind
Signed-off-by: Sam Alba <sam.alba@gmail.com>
This commit is contained in:
parent
fd31afeda0
commit
66929f8a63
@ -110,7 +110,7 @@ func FormatValue(val *compiler.Value) string {
|
||||
return "dagger.#Secret"
|
||||
}
|
||||
if val.IsConcreteR() != nil {
|
||||
return val.Cue().IncompleteKind().String()
|
||||
return val.IncompleteKindString()
|
||||
}
|
||||
// value representation in Cue
|
||||
valStr := fmt.Sprintf("%v", val.Cue())
|
||||
@ -121,7 +121,7 @@ func FormatValue(val *compiler.Value) string {
|
||||
// ValueDocString returns the value doc from the comment lines
|
||||
func ValueDocString(val *compiler.Value) string {
|
||||
docs := []string{}
|
||||
for _, c := range val.Cue().Doc() {
|
||||
for _, c := range val.Doc() {
|
||||
docs = append(docs, strings.TrimSpace(c.Text()))
|
||||
}
|
||||
doc := strings.Join(docs, " ")
|
||||
|
@ -57,15 +57,6 @@ var listCmd = &cobra.Command{
|
||||
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 = strings.ReplaceAll(valStr, "\n", "\\n")
|
||||
|
||||
if !viper.GetBool("all") {
|
||||
// skip input that is not overridable
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
"strconv"
|
||||
|
||||
"cuelang.org/go/cue"
|
||||
"cuelang.org/go/cue/ast"
|
||||
cueformat "cuelang.org/go/cue/format"
|
||||
)
|
||||
|
||||
@ -270,3 +271,11 @@ func (v *Value) Default() (*Value, bool) {
|
||||
val, hasDef := v.val.Default()
|
||||
return v.cc.Wrap(val), hasDef
|
||||
}
|
||||
|
||||
func (v *Value) Doc() []*ast.CommentGroup {
|
||||
return v.Cue().Doc()
|
||||
}
|
||||
|
||||
func (v *Value) IncompleteKindString() string {
|
||||
return v.Cue().IncompleteKind().String()
|
||||
}
|
||||
|
Reference in New Issue
Block a user