-
-
Notifications
You must be signed in to change notification settings - Fork 45
/
list_status.go
41 lines (35 loc) · 930 Bytes
/
list_status.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
package cmd
import (
"fmt"
"github.com/spf13/cobra"
"github.com/guumaster/hostctl/pkg/host"
)
// makeListStatusCmd represents the list enabled command
var makeListStatusCmd = func(cmd string) *cobra.Command {
status := ""
switch cmd {
case "enabled":
status = "on"
case "disabled":
status = "off"
}
return &cobra.Command{
Use: cmd,
Aliases: []string{status},
Short: fmt.Sprintf("Shows list of %s profiles on your hosts file.", cmd),
Long: fmt.Sprintf(`
Shows a detailed list of %s profiles on your hosts file with name, ip and host name.
`, cmd),
RunE: func(cmd *cobra.Command, args []string) error {
src, _ := cmd.Flags().GetString("host-file")
raw, _ := cmd.Flags().GetBool("raw")
cols, _ := cmd.Flags().GetStringSlice("column")
err := host.ListProfiles(src, &host.ListOptions{
RawTable: raw,
Columns: cols,
StatusFilter: status,
})
return err
},
}
}