diff --git a/references/cli/velaql.go b/references/cli/velaql.go index a25bc3cee..fda6cba80 100644 --- a/references/cli/velaql.go +++ b/references/cli/velaql.go @@ -21,6 +21,7 @@ import ( "context" "encoding/json" "fmt" + "strings" "github.com/spf13/cobra" "sigs.k8s.io/controller-runtime/pkg/client" @@ -47,7 +48,10 @@ func NewQlCommand(c common.Args, order string, ioStreams util.IOStreams) *cobra. cmd := &cobra.Command{ Use: "ql", Short: "Show result of executing velaQL.", - Long: "Show result of executing velaQL.", + Long: `Show result of executing velaQL, use it like: + vela ql --query "{=,=} + vela ql --file=./ql.cue +`, Example: `Users can query with a query statement: vela ql --query "{=,=}" They can also query by a ql file: @@ -133,11 +137,11 @@ func print(queryValue *value.Value, cmd *cobra.Command) error { return err } var out bytes.Buffer - err = json.Indent(&out, response, "", " ") + err = json.Indent(&out, response, "", " ") if err != nil { return err } - cmd.Printf("%s\n", out.String()) + cmd.Println(strings.Trim(strings.TrimSpace(out.String()), "\"")) return nil } diff --git a/references/cli/velaql_test.go b/references/cli/velaql_test.go index 58611950a..f90194829 100644 --- a/references/cli/velaql_test.go +++ b/references/cli/velaql_test.go @@ -76,7 +76,7 @@ export: "status" var buff = bytes.NewBufferString("") cmd.SetOut(buff) Expect(queryFromView(context.TODO(), k8sClient, arg, name, cmd)).Should(BeNil()) - Expect(buff.String()).Should(ContainSubstring(`my-value`)) + Expect(strings.TrimSpace(buff.String())).Should(BeEquivalentTo("my-value")) }) })