(args []string)
| 83 | } |
| 84 | |
| 85 | func (c *cleanCmd) execute(args []string) error { |
| 86 | if err := c.celer.Init(); err != nil { |
| 87 | return color.PrintError(err, "failed to init celer.") |
| 88 | } |
| 89 | |
| 90 | // Must check tool after celer initialized, since "downloads" will be assign value after init. |
| 91 | if err := buildtools.CheckTools(c.celer, "git"); err != nil { |
| 92 | return err |
| 93 | } |
| 94 | |
| 95 | if c.all { |
| 96 | if err := c.cleanAll(); err != nil { |
| 97 | return color.PrintError(err, "failed to clean all packages.") |
| 98 | } |
| 99 | } else { |
| 100 | if err := c.validateTargets(args); err != nil { |
| 101 | return color.PrintError(err, "invalid arguments.") |
| 102 | } |
| 103 | |
| 104 | if err := c.clean(args...); err != nil { |
| 105 | return color.PrintError(err, "failed to clean %s", strings.Join(args, ", ")) |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | return nil |
| 110 | } |
| 111 | |
| 112 | func (c *cleanCmd) validateTargets(targets []string) error { |
| 113 | if len(targets) == 0 { |
no test coverage detected