forked from alexellis/arkade
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinfo.go
58 lines (48 loc) · 1.39 KB
/
info.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
// Copyright (c) arkade author(s) 2022. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
package cmd
import (
"fmt"
"github.com/spf13/cobra"
)
func MakeInfo() *cobra.Command {
info := &cobra.Command{
Use: "info",
Short: "Find info about a Kubernetes app",
Long: "Find info about how to use the installed Kubernetes app",
Aliases: []string{"f"},
Example: ` arkade info [APP]
arkade info openfaas
arkade info inlets-operator
arkade info mongodb
arkade info
arkade info --help`,
SilenceUsage: true,
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
apps := GetApps()
keys := make([]string, 0, len(apps))
for k := range apps {
keys = append(keys, k)
}
return keys, cobra.ShellCompDirectiveDefault
},
}
info.RunE = func(cmd *cobra.Command, args []string) error {
if len(args) == 0 {
fmt.Println("Run arkade info APP_NAME for more")
return nil
}
if len(args) != 1 {
return fmt.Errorf("you can only get info about exactly one installed app")
}
appList := GetApps()
appName := args[0]
if _, ok := appList[appName]; !ok {
return fmt.Errorf("no info available for app: %s", appName)
}
fmt.Printf("Info for app: %s\n", appName)
fmt.Println(appList[appName].InfoMessage)
return nil
}
return info
}