From 6273a2932a2c9518b06eab068d9f065e882452f5 Mon Sep 17 00:00:00 2001 From: zelahi Date: Mon, 22 Jul 2019 16:06:25 -0700 Subject: [PATCH] TEMPLATE for prune command --- commands/hello.go | 27 ---------------------- commands/prune.go | 57 ++++++++++++++--------------------------------- commands/root.go | 1 - 3 files changed, 17 insertions(+), 68 deletions(-) delete mode 100644 commands/hello.go diff --git a/commands/hello.go b/commands/hello.go deleted file mode 100644 index d6cdd46d..00000000 --- a/commands/hello.go +++ /dev/null @@ -1,27 +0,0 @@ -package commands - -import ( - "fmt" - - "github.com/docker/buildx/version" - "github.com/docker/cli/cli" - "github.com/docker/cli/cli/command" - "github.com/spf13/cobra" -) - -func runHelloWorld(dockerCli command.Cli) error { - fmt.Println("hello world") - return nil -} - -func helloCmd(dockerCli command.Cli) *cobra.Command { - cmd := &cobra.Command{ - Use: "hello", - Short: "I think this is how cmds are added ", - Args: cli.ExactArgs(0), - RunE: func(cmd *cobra.Command, args []string) error { - return runHelloWorld(dockerCli) - }, - } - return cmd -} diff --git a/commands/prune.go b/commands/prune.go index 5f42bca2..f9dd65dd 100644 --- a/commands/prune.go +++ b/commands/prune.go @@ -1,51 +1,28 @@ -// Command used for prune package commands -import "fmt" -import "github.com/docker/cli/cli/command" +import ( + "fmt" + + "github.com/docker/cli/cli" + "github.com/docker/cli/cli/command" + "github.com/spf13/cobra" +) + +func runPrune(dockerCli command.Cli) error { + fmt.Println("ASDF run prune") + return nil +} func pruneCmd(dockerCli command.Cli) *cobra.Command { - fmt.Println("ASDF - pruneCmd") + fmt.Println("ASDF prune command added") cmd := &cobra.Command{ - Use: "docker buildx prune" - Short: "Cleans up the build cache" - Args: cli.NoArgs + Use: "prune", + Short: "clear the buildx build cache ", + Args: cli.ExactArgs(0), RunE: func(cmd *cobra.Command, args []string) error { - spaceReclaimed, output, err := runPrune(dockerCli, options) - if err != nil { - return err - } - - if output != "" { - fmt.Fprintln(dockerCli.Out(), output) - } - fmt.Fprintln(dockerCli.Out(), "Total reclaimed space:", units.HumanSize(float64(spaceReclaimed))) - return nil - + return runPrune(dockerCli) }, - Annotations: map[string]string{"version": "1.00"}, } - - // ToDo: Uncomment and test this out once we get the base feature working - //flags := cmd.Flags() - //flags.BoolVarP(&options.force, "force", "f", false, "Do not prompt for confirmation") - //flags.Var(&options.filter, "filter", "Provide filter values (e.g. 'until=')") - - const ( - normalWarning = `WARNING! This will remove all dangling build cache. Are you sure you want to continue?` - allCacheWarning = `WARNING! This will remove all build cache. Are you sure you want to continue?` - ) - return cmd - -} - - -func runPrune(dockerCli command.Cli, options pruneOptions) (spaceReclaimed uint64, output string, err error) { - fmt.Println("ASDF runPrune - Hello world") - - // ToDo: Implement this function - - return 0, "Not implemented", nil } diff --git a/commands/root.go b/commands/root.go index 82167323..2adfb5dc 100644 --- a/commands/root.go +++ b/commands/root.go @@ -35,7 +35,6 @@ func addCommands(cmd *cobra.Command, dockerCli command.Cli) { installCmd(dockerCli), uninstallCmd(dockerCli), versionCmd(dockerCli), - helloCmd(dockerCli), pruneCmd(dockerCli), imagetoolscmd.RootCmd(dockerCli), )