mirror of
https://github.com/pcvolkmer/docker-pps.git
synced 2025-04-19 17:56:50 +00:00
Replace flag with github.com/spf13/pflag
This commit is contained in:
parent
9373657fb7
commit
5495ecc95a
24
go.mod
24
go.mod
@ -2,28 +2,30 @@ module github.com/pcvolkmer/docker-pps
|
||||
|
||||
go 1.17
|
||||
|
||||
require github.com/docker/docker v20.10.12+incompatible
|
||||
require (
|
||||
github.com/docker/docker v20.10.12+incompatible
|
||||
github.com/spf13/pflag v1.0.5
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/Microsoft/go-winio v0.4.17 // indirect
|
||||
github.com/containerd/containerd v1.5.9 // indirect
|
||||
github.com/docker/distribution v2.7.1+incompatible // indirect
|
||||
github.com/Microsoft/go-winio v0.5.1 // indirect
|
||||
github.com/containerd/containerd v1.6.0 // indirect
|
||||
github.com/docker/distribution v2.8.0+incompatible // indirect
|
||||
github.com/docker/go-connections v0.4.0 // indirect
|
||||
github.com/docker/go-units v0.4.0 // indirect
|
||||
github.com/gogo/protobuf v1.3.2 // indirect
|
||||
github.com/golang/protobuf v1.5.0 // indirect
|
||||
github.com/golang/protobuf v1.5.2 // indirect
|
||||
github.com/gorilla/mux v1.8.0 // indirect
|
||||
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect
|
||||
github.com/morikuni/aec v1.0.0 // indirect
|
||||
github.com/opencontainers/go-digest v1.0.0 // indirect
|
||||
github.com/opencontainers/image-spec v1.0.2 // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/sirupsen/logrus v1.8.1 // indirect
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110 // indirect
|
||||
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22 // indirect
|
||||
golang.org/x/time v0.0.0-20211116232009-f0f3c7e86c11 // indirect
|
||||
google.golang.org/genproto v0.0.0-20201110150050-8816d57aaa9a // indirect
|
||||
google.golang.org/grpc v1.43.0 // indirect
|
||||
golang.org/x/net v0.0.0-20211216030914-fe4d6282115f // indirect
|
||||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect
|
||||
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 // indirect
|
||||
google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa // indirect
|
||||
google.golang.org/grpc v1.44.0 // indirect
|
||||
google.golang.org/protobuf v1.27.1 // indirect
|
||||
gotest.tools/v3 v3.1.0 // indirect
|
||||
)
|
||||
|
25
main.go
25
main.go
@ -2,11 +2,13 @@ package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
flag "github.com/spf13/pflag"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/client"
|
||||
)
|
||||
@ -24,17 +26,32 @@ var (
|
||||
q *bool
|
||||
h *string
|
||||
uids *string
|
||||
help *bool
|
||||
)
|
||||
|
||||
func init() {
|
||||
q = flag.Bool("q", false, "Only display process IDs")
|
||||
h = flag.String("host", "", "Container host")
|
||||
uids = flag.String("uid", "", "Only display processes for Username/UID(s)")
|
||||
q = flag.BoolP("quiet", "q", false, "Only display process IDs")
|
||||
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")
|
||||
}
|
||||
|
||||
func main() {
|
||||
flag.Usage = func() {
|
||||
fmt.Fprintln(os.Stderr, "\nUsage: docker-pps [OPTIONS]\n\nShow list of Processes running in docker containers\n\nOptions:")
|
||||
flag.PrintDefaults()
|
||||
}
|
||||
|
||||
flag.CommandLine.MarkHidden("help")
|
||||
flag.CommandLine.SortFlags = false
|
||||
|
||||
flag.Parse()
|
||||
|
||||
if *help {
|
||||
flag.Usage()
|
||||
return
|
||||
}
|
||||
|
||||
var opts []client.Opt
|
||||
if *h != "" {
|
||||
opts = append(opts, client.WithHost(*h))
|
||||
|
Loading…
x
Reference in New Issue
Block a user