/
get.go
48 lines (37 loc) · 1.04 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
package cmd
import (
"bytes"
"fmt"
"html/template"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
var getCmd = &cobra.Command{
Use: "get",
Short: "Show informations about a given namespace.",
Long: `This command display informations from a given namespace such as the list of exposed services
or the url where you can join services throw ingress.`,
Run: func(cmd *cobra.Command, args []string) {
runGet()
},
}
func NewGetCommand() *cobra.Command {
addCommonNamespaceCommandFlags(getCmd)
getCmd.AddCommand(NewGetNamespacesCommand())
getCmd.AddCommand(NewGetServicesCommand())
return getCmd
}
func runGet() {
tpl := template.Must(template.New("getCmd").Parse(`
Using the get command without any sub-command makes no sens. Please use one of the following sub-command :
{{range .}}
- {{.}}
{{end}}
`))
data := []string{"get services", "get namespaces"}
contents := bytes.Buffer{}
if err := tpl.Execute(&contents, data); err != nil {
logrus.Fatalf("error when executing template : %v", err)
}
fmt.Println(contents.String())
}