cmd: allow invoking without plugin

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
Tonis Tiigi
2019-04-11 09:09:03 -07:00
parent 21754a42b1
commit 81d689e2e4
3 changed files with 31 additions and 7 deletions

View File

@ -6,14 +6,17 @@ import (
"github.com/spf13/cobra"
)
func NewRootCmd(dockerCli command.Cli) *cobra.Command {
func NewRootCmd(name string, isPlugin bool, dockerCli command.Cli) *cobra.Command {
cmd := &cobra.Command{
Short: "Build with BuildKit",
Use: "buildx",
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
return plugin.PersistentPreRunE(cmd, args)
},
Use: name,
}
if isPlugin {
cmd.PersistentPreRunE = func(cmd *cobra.Command, args []string) error {
return plugin.PersistentPreRunE(cmd, args)
}
}
addCommands(cmd, dockerCli)
return cmd
}