-
-
Notifications
You must be signed in to change notification settings - Fork 45
/
list.go
44 lines (34 loc) · 1.11 KB
/
list.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
package cmd
import (
"github.com/spf13/cobra"
"github.com/guumaster/hostctl/pkg/host"
)
// listCmd represents the list command
var listCmd = &cobra.Command{
Use: "list",
Short: "Shows a detailed list of profiles on your hosts file.",
Long: `
Shows a detailed list of profiles on your hosts file with name, ip and host name.
You can filter by profile name.
The "default" profile is all the content that is not handled by hostctl tool.
`,
RunE: func(cmd *cobra.Command, args []string) error {
profile, _ := cmd.Flags().GetString("profile")
src, _ := cmd.Flags().GetString("host-file")
raw, _ := cmd.Flags().GetBool("raw")
cols, _ := cmd.Flags().GetStringSlice("column")
err := host.ListProfiles(src, &host.ListOptions{
Profile: profile,
RawTable: raw,
Columns: cols,
})
return err
},
}
func init() {
rootCmd.AddCommand(listCmd)
listCmd.AddCommand(makeListStatusCmd("enabled"))
listCmd.AddCommand(makeListStatusCmd("disabled"))
listCmd.PersistentFlags().StringSliceP("column", "c", nil, "Columns to show on lists")
listCmd.PersistentFlags().Bool("raw", false, "Output without table borders")
}