Skip to content

Commit

Permalink
Add list command
Browse files Browse the repository at this point in the history
  • Loading branch information
oleewere committed May 3, 2019
1 parent ac463e6 commit 67dbbac
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,26 @@ func main() {
},
}

listCommand := cli.Command{
Name: "list",
Aliases: []string{"ls"},
Usage: "Print all registered CM servers",
Action: func(c *cli.Context) error {
cmServerEntries := cm.ListCMRegistryEntries()
var tableData [][]string
for _, cmServer := range cmServerEntries {
activeValue := "false"
if cmServer.Active {
activeValue = "true"
}
tableData = append(tableData, []string{cmServer.Name, cmServer.Hostname, strconv.Itoa(cmServer.Port), cmServer.Protocol,
cmServer.Username, "********", cmServer.Cluster, cmServer.ConnectionProfile, activeValue})
}
printTable("CM SERVERS:", []string{"Name", "HOSTNAME", "PORT", "PROTOCOL", "USER", "PASSWORD", "CLUSTER", "PROFILE", "ACTIVE"}, tableData, c)
return nil
},
}

profileCommand := cli.Command{
Name: "profiles",
Usage: "Connection profiles related commands",
Expand Down Expand Up @@ -299,6 +319,7 @@ func main() {

app.Commands = append(app.Commands, initCommand)
app.Commands = append(app.Commands, createCommand)
app.Commands = append(app.Commands, listCommand)
app.Commands = append(app.Commands, deleteCommand)
app.Commands = append(app.Commands, clearCommand)
app.Commands = append(app.Commands, useCommand)
Expand Down

0 comments on commit 67dbbac

Please sign in to comment.