From a4b9fd69c9a56fce6c464a5a58331304cd79bca1 Mon Sep 17 00:00:00 2001 From: Paul-Christian Volkmer Date: Tue, 22 Feb 2022 10:22:36 +0100 Subject: [PATCH] Changed behavior of container host param --- main.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index c7f6b7b..c353c05 100644 --- a/main.go +++ b/main.go @@ -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...)