Commit cb1b4979 authored by Audrius Butkevicius's avatar Audrius Butkevicius

Use standard libs when possible

parent c37c3134
......@@ -36,10 +36,7 @@ var errorCommand = cli.Command{
Usage: "Push an error to active clients",
Requires: &cli.Requires{"error message..."},
Action: func(c *cli.Context) {
err := ""
for _, item := range c.Args() {
err += " " + item
}
err := strings.Join(c.Args(), " ")
response := httpPost(c, "error", strings.TrimSpace(err))
if response.StatusCode != 200 {
err = fmt.Sprint("Failed to push error\nStatus code: ", response.StatusCode)
......
......@@ -26,11 +26,7 @@ var nodeCommand = cli.Command{
}
fmt.Fprintln(writer, "ID:\t", node.NodeID, "\t")
fmt.Fprintln(writer, "Name:\t", node.Name, "\t(name)")
fmt.Fprintf(writer, "Address:\t")
for _, item := range node.Addresses {
fmt.Fprintf(writer, " %s", item)
}
fmt.Fprintln(writer, "\t(address)")
fmt.Fprintln(writer, "Address:\t", strings.Join(node.Addresses, " "), "\t(address)")
first = false
}
writer.Flush()
......@@ -115,9 +111,7 @@ var nodeCommand = cli.Command{
case "name":
fmt.Println(node.Name)
case "address":
for _, address := range node.Addresses {
fmt.Println(address)
}
fmt.Println(strings.Join(node.Addresses, "\n"))
default:
die("Invalid property: " + arg + "\nAvailable properties: name, address")
}
......
......@@ -19,12 +19,7 @@ var optionsCommand = cli.Command{
cfg := getConfig(c).Options
writer := newTableWriter()
fmt.Fprint(writer, "Sync protocol listen addresses:\t")
for _, address := range cfg.ListenAddress {
fmt.Fprintf(writer, "%s ", address)
}
fmt.Fprintf(writer, "\t(address)\n")
fmt.Fprintf(writer, "Sync protocol listen addresses:\t%s\t(address)\n", strings.Join(cfg.ListenAddress, " "))
fmt.Fprintf(writer, "Global discovery enabled:\t%t\t(globalannenabled)\n", cfg.GlobalAnnEnabled)
fmt.Fprintf(writer, "Global discovery server:\t%s\t(globalannserver)\n", cfg.GlobalAnnServer)
......@@ -62,9 +57,7 @@ var optionsCommand = cli.Command{
arg := c.Args()[0]
switch strings.ToLower(arg) {
case "address":
for _, item := range cfg.ListenAddress {
fmt.Println(item)
}
fmt.Printf("%s\n", strings.Join(cfg.ListenAddress, "\n"))
case "globalannenabled":
fmt.Println(cfg.GlobalAnnEnabled)
case "globalannserver":
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment