clean

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 8, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

cmd/product/clean/clean.go

Index

Constants

This section is empty.

Variables

View Source
var CleanCmd = &cobra.Command{
	Use: "clean",
	RunE: func(cmd *cobra.Command, _ []string) error {
		presenter := ui.NewPresenter(cmd.OutOrStdout(), cmd.ErrOrStderr())
		ctx := cmd.Context()

		presenter.Header("--- Cleaning Local Project Files ---")

		dirsToRemove := []string{"./bin"}
		for _, dir := range dirsToRemove {
			presenter.Step("Removing directory: %s...", dir)
			if err := os.RemoveAll(dir); err != nil {
				if !os.IsNotExist(err) {
					return fmt.Errorf("failed to remove directory %s: %w", dir, err)
				}
			}
		}

		filesToRemove := []string{
			"coverage.out",
			"context_commit.md",
			"context_pr.md",
			"context_export_project.md",
		}
		for _, file := range filesToRemove {
			presenter.Step("Removing file: %s...", file)
			if err := os.Remove(file); err != nil {
				if !os.IsNotExist(err) {
					return fmt.Errorf("failed to remove file %s: %w", file, err)
				}
			}
		}

		presenter.Step("Cleaning Go build and test caches...")
		if err := globals.ExecClient.Execute(ctx, ".", "go", "clean", "-cache", "-testcache"); err != nil {
			return fmt.Errorf("failed to run 'go clean': %w", err)
		}

		presenter.Newline()
		presenter.Success("Project files cleaned successfully.")
		globals.AppLogger.InfoContext(ctx, "Project cleanup completed.")
		return nil
	},
}

CleanCmd represents the clean command

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL