mirror of https://github.com/docker/compose.git
Use v2 of urfave/cli
Signed-off-by: Guillaume Lours <guillaume.lours@docker.com>
This commit is contained in:
parent
83e9843ef2
commit
8db55e8c5c
|
@ -29,7 +29,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
var contextCommand = cli.Command{
|
var contextCommand = cli.Command{
|
||||||
|
|
|
@ -37,7 +37,7 @@ import (
|
||||||
"github.com/docker/api/client"
|
"github.com/docker/api/client"
|
||||||
"github.com/golang/protobuf/ptypes/empty"
|
"github.com/golang/protobuf/ptypes/empty"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
var exampleCommand = cli.Command{
|
var exampleCommand = cli.Command{
|
||||||
|
|
16
cmd/main.go
16
cmd/main.go
|
@ -38,7 +38,7 @@ import (
|
||||||
|
|
||||||
"github.com/docker/api/context"
|
"github.com/docker/api/context"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -61,12 +61,12 @@ func main() {
|
||||||
app.UseShortOptionHandling = true
|
app.UseShortOptionHandling = true
|
||||||
app.EnableBashCompletion = true
|
app.EnableBashCompletion = true
|
||||||
app.Flags = []cli.Flag{
|
app.Flags = []cli.Flag{
|
||||||
cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
Name: "debug",
|
Name: "debug",
|
||||||
Usage: "enable debug output in the logs",
|
Usage: "enable debug output in the logs",
|
||||||
},
|
},
|
||||||
context.ConfigFlag,
|
&context.ConfigFlag,
|
||||||
context.ContextFlag,
|
&context.ContextFlag,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make a copy of the default HelpPrinter function
|
// Make a copy of the default HelpPrinter function
|
||||||
|
@ -87,7 +87,7 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
app.Before = func(clix *cli.Context) error {
|
app.Before = func(clix *cli.Context) error {
|
||||||
if clix.GlobalBool("debug") {
|
if clix.Bool("debug") {
|
||||||
logrus.SetLevel(logrus.DebugLevel)
|
logrus.SetLevel(logrus.DebugLevel)
|
||||||
}
|
}
|
||||||
ctx, err := context.GetContext()
|
ctx, err := context.GetContext()
|
||||||
|
@ -100,9 +100,9 @@ func main() {
|
||||||
// TODO select backend based on context.Metadata.Type
|
// TODO select backend based on context.Metadata.Type
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
app.Commands = []cli.Command{
|
app.Commands = []*cli.Command{
|
||||||
contextCommand,
|
&contextCommand,
|
||||||
exampleCommand,
|
&exampleCommand,
|
||||||
}
|
}
|
||||||
|
|
||||||
sort.Sort(cli.FlagsByName(app.Flags))
|
sort.Sort(cli.FlagsByName(app.Flags))
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/mitchellh/go-homedir"
|
"github.com/mitchellh/go-homedir"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -19,15 +19,16 @@ var (
|
||||||
ConfigFlag = cli.StringFlag{
|
ConfigFlag = cli.StringFlag{
|
||||||
Name: "config",
|
Name: "config",
|
||||||
Usage: "Location of client config files `DIRECTORY`",
|
Usage: "Location of client config files `DIRECTORY`",
|
||||||
EnvVar: "DOCKER_CONFIG",
|
EnvVars: []string{"DOCKER_CONFIG"},
|
||||||
Value: filepath.Join(home(), configFileDir),
|
Value: filepath.Join(home(), configFileDir),
|
||||||
Destination: &ConfigDir,
|
Destination: &ConfigDir,
|
||||||
}
|
}
|
||||||
|
|
||||||
ContextFlag = cli.StringFlag{
|
ContextFlag = cli.StringFlag{
|
||||||
Name: "context, c",
|
Name: "context",
|
||||||
|
Aliases: []string{"c"},
|
||||||
Usage: "Name of the context `CONTEXT` to use to connect to the daemon (overrides DOCKER_HOST env var and default context set with \"docker context use\")",
|
Usage: "Name of the context `CONTEXT` to use to connect to the daemon (overrides DOCKER_HOST env var and default context set with \"docker context use\")",
|
||||||
EnvVar: "DOCKER_CONTEXT",
|
EnvVars: []string{"DOCKER_CONTEXT"},
|
||||||
Destination: &ContextName,
|
Destination: &ContextName,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
@ -39,7 +39,7 @@ import (
|
||||||
"github.com/golang/protobuf/ptypes/empty"
|
"github.com/golang/protobuf/ptypes/empty"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
@ -50,17 +50,17 @@ func main() {
|
||||||
app.UseShortOptionHandling = true
|
app.UseShortOptionHandling = true
|
||||||
app.EnableBashCompletion = true
|
app.EnableBashCompletion = true
|
||||||
app.Flags = []cli.Flag{
|
app.Flags = []cli.Flag{
|
||||||
cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
Name: "debug",
|
Name: "debug",
|
||||||
Usage: "enable debug output in the logs",
|
Usage: "enable debug output in the logs",
|
||||||
},
|
},
|
||||||
cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "address,a",
|
Name: "address,a",
|
||||||
Usage: "address of the server",
|
Usage: "address of the server",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
app.Before = func(clix *cli.Context) error {
|
app.Before = func(clix *cli.Context) error {
|
||||||
if clix.GlobalBool("debug") {
|
if clix.Bool("debug") {
|
||||||
logrus.SetLevel(logrus.DebugLevel)
|
logrus.SetLevel(logrus.DebugLevel)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -73,7 +73,7 @@ func main() {
|
||||||
s := server.New()
|
s := server.New()
|
||||||
|
|
||||||
// listen on a socket to accept connects
|
// listen on a socket to accept connects
|
||||||
l, err := net.Listen("unix", clix.GlobalString("address"))
|
l, err := net.Listen("unix", clix.String("address"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "listen unix socket")
|
return errors.Wrap(err, "listen unix socket")
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ func main() {
|
||||||
s.Stop()
|
s.Stop()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
logrus.WithField("address", clix.GlobalString("address")).Info("serving daemon API")
|
logrus.WithField("address", clix.String("address")).Info("serving daemon API")
|
||||||
// start the GRPC server to serve on the listener
|
// start the GRPC server to serve on the listener
|
||||||
return s.Serve(l)
|
return s.Serve(l)
|
||||||
}
|
}
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -10,7 +10,7 @@ require (
|
||||||
github.com/pkg/errors v0.9.1
|
github.com/pkg/errors v0.9.1
|
||||||
github.com/prometheus/client_golang v1.5.1 // indirect
|
github.com/prometheus/client_golang v1.5.1 // indirect
|
||||||
github.com/sirupsen/logrus v1.5.0
|
github.com/sirupsen/logrus v1.5.0
|
||||||
github.com/urfave/cli v1.22.4
|
github.com/urfave/cli/v2 v2.2.0
|
||||||
google.golang.org/grpc v1.28.1
|
google.golang.org/grpc v1.28.1
|
||||||
google.golang.org/protobuf v1.21.0
|
google.golang.org/protobuf v1.21.0
|
||||||
)
|
)
|
||||||
|
|
4
go.sum
4
go.sum
|
@ -105,8 +105,8 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf
|
||||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||||
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
|
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
|
||||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||||
github.com/urfave/cli v1.22.4 h1:u7tSpNPPswAFymm8IehJhy4uJMlUuU/GmqSkvJ1InXA=
|
github.com/urfave/cli/v2 v2.2.0 h1:JTTnM6wKzdA0Jqodd966MVj4vWbbquZykeX1sKbe2C4=
|
||||||
github.com/urfave/cli v1.22.4/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
github.com/urfave/cli/v2 v2.2.0/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ=
|
||||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||||
|
|
Loading…
Reference in New Issue