Skip to content

Conversation

rajat404
Copy link
Contributor

@rajat404 rajat404 commented Mar 6, 2020

No description provided.


for _, ins := range insts {
fmt.Printf("%s\n", ins)
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. we should use bytes.Buffer
  2. ideally would prefer having custom type instances []instance and defining formatted outputs from it, since that's more extensible. you could refer projects

instanceCommand.StringVar(&instanceArgs.Regex, "regex", "", "search instances by regex")
instanceCommand.BoolVar(&instanceArgs.HostMapping, "host_mapping", false, "return the search results in `/etc/hosts` file format")
instanceCommand.BoolVar(&instanceArgs.IPOnly, "ip_only", false, "returns comma separated list of IPs for matching hosts")
instanceCommand.StringVar(&args.Login.Session, "session", "login-session", "login sesssion name")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should also mentioned host_mapping takes higher priority than ip_only

}
output = strings.TrimRight(output, ",")
fmt.Printf("%s", output)
fmt.Printf("\n")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can get the ip list with our custom type Instances []Instance with IPs defined on the struct.

ips := Instances(insts).IPs()
strings.Join(ips, ",")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants