Skip to content

Commit

Permalink
use displayName, not nickname
Browse files Browse the repository at this point in the history
  • Loading branch information
stanaka committed Feb 10, 2016
1 parent 6a9e3e2 commit c9032f0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
16 changes: 12 additions & 4 deletions commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ var commandUpdate = cli.Command{
Action: doUpdate,
Flags: []cli.Flag{
cli.StringFlag{Name: "name, n", Value: "", Usage: "Update hostname."},
cli.StringFlag{Name: "displayname", Value: "", Usage: "Update displayname."},
cli.StringFlag{Name: "status, st", Value: "", Usage: "Update status."},
cli.StringSliceFlag{
Name: "roleFullname, R",
Expand Down Expand Up @@ -189,7 +190,7 @@ var commandDocs = map[string]commandDoc{
"status": {"", "[-v|verbose] <hostId>"},
"hosts": {"", "[--verbose | -v] [--name | -n <name>] [--service | -s <service>] [[--role | -r <role>]...] [[--status | --st <status>]...]"},
"create": {"", "[--status | -st <status>] [--roleFullname | -R <service:role>] <hostName>"},
"update": {"", "[--name | -n <name>] [--status | -st <status>] [--roleFullname | -R <service:role>] <hostIds...> ]"},
"update": {"", "[--name | -n <name>] [--displayname <displayname>] [--status | -st <status>] [--roleFullname | -R <service:role>] <hostIds...> ]"},
"throw": {"", "[--host | -h <hostId>] [--service | -s <service>] stdin"},
"fetch": {"", "[--name | -n <metricName>] hostIds..."},
"retire": {"", "hostIds..."},
Expand Down Expand Up @@ -253,7 +254,6 @@ func doStatus(c *cli.Context) {
format := &HostFormat{
ID: host.ID,
Name: host.Name,
Nickname: host.Nickname,
DisplayName: host.DisplayName,
Status: host.Status,
RoleFullnames: host.GetRoleFullnames(),
Expand Down Expand Up @@ -291,7 +291,6 @@ func doHosts(c *cli.Context) {
format := &HostFormat{
ID: host.ID,
Name: host.Name,
Nickname: host.Nickname,
DisplayName: host.DisplayName,
Status: host.Status,
RoleFullnames: host.GetRoleFullnames(),
Expand Down Expand Up @@ -338,6 +337,7 @@ func doUpdate(c *cli.Context) {
conffile := c.GlobalString("conf")
argHostIDs := c.Args()
optName := c.String("name")
optDisplayName := c.String("displayname")
optStatus := c.String("status")
optRoleFullnames := c.StringSlice("roleFullname")

Expand All @@ -350,9 +350,10 @@ func doUpdate(c *cli.Context) {
}

needUpdateHostStatus := optStatus != ""
needUpdateHost := (optName != "" || len(optRoleFullnames) > 0)
needUpdateHost := (optName != "" || optDisplayName != "" || len(optRoleFullnames) > 0)

if !needUpdateHostStatus && !needUpdateHost {
logger.Log("update", "at least one argumet is required.")
cli.ShowCommandHelp(c, "update")
os.Exit(1)
}
Expand All @@ -375,8 +376,15 @@ func doUpdate(c *cli.Context) {
} else {
name = optName
}
displayname := ""
if optDisplayName == "" {
displayname = host.DisplayName
} else {
displayname = optDisplayName
}
_, err = client.UpdateHost(hostID, &mkr.UpdateHostParam{
Name: name,
DisplayName: displayname,
RoleFullnames: optRoleFullnames,
Meta: meta,
})
Expand Down
1 change: 0 additions & 1 deletion format.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
type HostFormat struct {
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Nickname string `json:"nickname,omitempty"`
DisplayName string `json:"displayName,omitempty"`
Status string `json:"status,omitempty"`
Memo string `json:"memo,omitempty"`
Expand Down

0 comments on commit c9032f0

Please sign in to comment.