cmd/output: implemented list --all
Signed-off-by: Sam Alba <sam.alba@gmail.com>
This commit is contained in:
parent
1a59c9c40b
commit
270d8b4775
@ -54,10 +54,15 @@ var listCmd = &cobra.Command{
|
|||||||
fmt.Fprintln(w, "Output\tType\tValue\tDescription")
|
fmt.Fprintln(w, "Output\tType\tValue\tDescription")
|
||||||
|
|
||||||
for _, out := range outputs {
|
for _, out := range outputs {
|
||||||
isConcrete := (out.IsConcreteR() == nil)
|
|
||||||
valStr := "-"
|
valStr := "-"
|
||||||
if isConcrete {
|
|
||||||
valStr, _ = out.Cue().String()
|
if out.IsConcreteR() == nil {
|
||||||
|
valStr, err = out.Cue().String()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
} else if !viper.GetBool("all") {
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
valStr = strings.ReplaceAll(valStr, "\n", "\\n")
|
valStr = strings.ReplaceAll(valStr, "\n", "\\n")
|
||||||
@ -79,3 +84,11 @@ var listCmd = &cobra.Command{
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
listCmd.Flags().BoolP("all", "a", false, "List all outputs (include non-concrete)")
|
||||||
|
|
||||||
|
if err := viper.BindPFlags(listCmd.Flags()); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user