@@ -13,20 +13,23 @@ import (
1313
1414func newIntegrationsCommand (options core.BindOptions ) * cobra.Command {
1515 var name string
16+ var full bool
1617
1718 cmd := & cobra.Command {
1819 Use : "integrations" ,
1920 Short : "List or describe available integration definitions" ,
2021 Args : cobra .NoArgs ,
2122 }
2223 cmd .Flags ().StringVar (& name , "name" , "" , "integration definition name" )
23- core .Bind (cmd , & integrationsCommand {name : & name }, options )
24+ cmd .Flags ().BoolVar (& full , "full" , false , "show full output including all fields" )
25+ core .Bind (cmd , & integrationsCommand {name : & name , full : & full }, options )
2426
2527 return cmd
2628}
2729
2830type integrationsCommand struct {
2931 name * string
32+ full * bool
3033}
3134
3235func (c * integrationsCommand ) Execute (ctx core.CommandContext ) error {
@@ -40,14 +43,27 @@ func (c *integrationsCommand) Execute(ctx core.CommandContext) error {
4043 return err
4144 }
4245
46+ integrations := response .GetIntegrations ()
4347 if ! ctx .Renderer .IsText () {
44- return ctx .Renderer .Render (response .GetIntegrations ())
48+ if c .full != nil && * c .full {
49+ return ctx .Renderer .Render (integrations )
50+ }
51+
52+ summary := make ([]map [string ]string , len (integrations ))
53+ for i , integration := range integrations {
54+ summary [i ] = map [string ]string {
55+ "name" : integration .GetName (),
56+ "label" : integration .GetLabel (),
57+ "description" : integration .GetDescription (),
58+ }
59+ }
60+ return ctx .Renderer .Render (summary )
4561 }
4662
4763 return ctx .Renderer .RenderText (func (stdout io.Writer ) error {
4864 writer := tabwriter .NewWriter (stdout , 0 , 8 , 2 , ' ' , 0 )
4965 _ , _ = fmt .Fprintln (writer , "NAME\t LABEL\t DESCRIPTION" )
50- for _ , integration := range response . GetIntegrations () {
66+ for _ , integration := range integrations {
5167 _ , _ = fmt .Fprintf (writer , "%s\t %s\t %s\n " , integration .GetName (), integration .GetLabel (), integration .GetDescription ())
5268 }
5369 return writer .Flush ()
0 commit comments