-
Notifications
You must be signed in to change notification settings - Fork 51
/
get.go
61 lines (51 loc) · 1.24 KB
/
get.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package get
import (
"os"
"github.com/jenkins-x-plugins/jx-gitops/pkg/plugins"
"github.com/jenkins-x/jx-helpers/v3/pkg/cobras/helper"
"github.com/jenkins-x/jx-helpers/v3/pkg/cobras/templates"
"github.com/jenkins-x/jx-helpers/v3/pkg/table"
"github.com/spf13/cobra"
)
// Options is the start of the data required to perform the operation.
// As new fields are added, add them here instead of
// referencing the cmd.Flags()
type Options struct {
}
var (
cmdLong = templates.LongDesc(`
Display the binary plugins
`)
cmdExample = templates.Examples(`
# list all binary plugins
jx plugin get
`)
)
// NewCmdPluginGet creates the command
func NewCmdPluginGet() (*cobra.Command, *Options) {
o := &Options{}
cmd := &cobra.Command{
Use: "get",
Short: "Display the binary plugins",
Long: cmdLong,
Example: cmdExample,
Aliases: []string{"list", "ls"},
Run: func(cmd *cobra.Command, args []string) {
err := o.Run()
helper.CheckErr(err)
},
}
return cmd, o
}
// Run implements this command
func (o *Options) Run() error {
out := os.Stdout
t := table.CreateTable(out)
t.AddRow("NAME", "VERSION")
for i := range plugins.Plugins {
p := &plugins.Plugins[i]
t.AddRow(p.Name, p.Spec.Version)
}
t.Render()
return nil
}