1
0
mirror of https://github.com/pcvolkmer/docker-pps.git synced 2025-04-19 17:56:50 +00:00

Changed behavior of container host param

This commit is contained in:
Paul-Christian Volkmer 2022-02-22 10:22:36 +01:00
parent 5495ecc95a
commit a4b9fd69c9

15
main.go
View File

@ -31,7 +31,7 @@ var (
func init() {
q = flag.BoolP("quiet", "q", false, "Only display process IDs")
h = flag.StringP("host", "h", "", "Container `host`")
h = flag.StringP("host", "H", "", "Container `host`")
uids = flag.String("uid", "", "Only display processes for `user`name/UID(s)")
help = flag.Bool("help", false, "Show this help text")
}
@ -54,7 +54,18 @@ func main() {
var opts []client.Opt
if *h != "" {
opts = append(opts, client.WithHost(*h))
if !strings.Contains(*h, "//") {
*h = "tcp://" + *h
}
if u, err := client.ParseHostURL(*h); err == nil {
if u.Port() != "" {
opts = append(opts, client.WithHost(*h))
} else {
opts = append(opts, client.WithHost(*h+":2375"))
}
} else {
log.Fatal(err)
}
}
dc, err := client.NewClientWithOpts(opts...)