| 27 | } |
| 28 | |
| 29 | func (c *cleanCmd) Command(celer *configs.Celer) *cobra.Command { |
| 30 | c.celer = celer |
| 31 | command := &cobra.Command{ |
| 32 | Use: "clean", |
| 33 | Short: "Remove build cache and clean source repository.", |
| 34 | Long: `Remove build cache and clean source repository. |
| 35 | |
| 36 | This command removes build artifacts and caches for specified packages or |
| 37 | projects. It can optionally clean dependencies recursively and handle both |
| 38 | release and development builds. |
| 39 | |
| 40 | Examples: |
| 41 | celer clean x264@stable # Clean specific package |
| 42 | celer clean my-project # Clean project |
| 43 | celer clean x264@stable --dev # Clean dev build cache |
| 44 | celer clean automake@1.18 --recursive # Clean with dependencies |
| 45 | celer clean --all # Clean all packages |
| 46 | celer clean x264@stable ffmpeg@3.4.13 --recursive # Clean multiple packages`, |
| 47 | Args: c.validateArgs, |
| 48 | RunE: func(cmd *cobra.Command, args []string) error { |
| 49 | return c.execute(args) |
| 50 | }, |
| 51 | ValidArgsFunction: c.completion, |
| 52 | } |
| 53 | |
| 54 | // Register flags. |
| 55 | command.Flags().BoolVarP(&c.recursive, "recursive", "r", false, "clean package/project along with its depedencies.") |
| 56 | command.Flags().BoolVarP(&c.dev, "dev", "d", false, "clean package/project for dev mode.") |
| 57 | command.Flags().BoolVarP(&c.all, "all", "a", false, "clean all packages.") |
| 58 | |
| 59 | // Silence cobra's error and usage output to avoid duplicate messages. |
| 60 | command.SilenceErrors = true |
| 61 | command.SilenceUsage = true |
| 62 | return command |
| 63 | } |
| 64 | |
| 65 | func (c *cleanCmd) validateArgs(cmd *cobra.Command, args []string) error { |
| 66 | all, err := cmd.Flags().GetBool("all") |