diff --git a/cobraadaptor/adaptor.go b/cobraadaptor/adaptor.go index 55538dd98f..a87c75206a 100644 --- a/cobraadaptor/adaptor.go +++ b/cobraadaptor/adaptor.go @@ -6,6 +6,7 @@ import ( "github.com/docker/docker/api/client/image" "github.com/docker/docker/api/client/network" "github.com/docker/docker/api/client/node" + "github.com/docker/docker/api/client/plugin" "github.com/docker/docker/api/client/registry" "github.com/docker/docker/api/client/service" "github.com/docker/docker/api/client/swarm" @@ -81,6 +82,7 @@ func NewCobraAdaptor(clientFlags *cliflags.ClientFlags) CobraAdaptor { system.NewVersionCommand(dockerCli), volume.NewVolumeCommand(dockerCli), ) + plugin.NewPluginCommand(rootCmd, dockerCli) rootCmd.PersistentFlags().BoolP("help", "h", false, "Print usage") rootCmd.PersistentFlags().MarkShorthandDeprecated("help", "please use --help") diff --git a/error.go b/error.go new file mode 100644 index 0000000000..902d1b6e49 --- /dev/null +++ b/error.go @@ -0,0 +1,21 @@ +package cli + +import "bytes" + +// Errors is a list of errors. +// Useful in a loop if you don't want to return the error right away and you want to display after the loop, +// all the errors that happened during the loop. +type Errors []error + +func (errs Errors) Error() string { + if len(errs) < 1 { + return "" + } + var buf bytes.Buffer + buf.WriteString(errs[0].Error()) + for _, err := range errs[1:] { + buf.WriteString(", ") + buf.WriteString(err.Error()) + } + return buf.String() +}