| 24 | } |
| 25 | |
| 26 | func (r *removeCmd) Command(celer *configs.Celer) *cobra.Command { |
| 27 | r.celer = celer |
| 28 | command := &cobra.Command{ |
| 29 | Use: "remove", |
| 30 | Short: "Remove installed packages, optionally with their dependencies, build cache, and package files.", |
| 31 | Long: `Remove installed packages, optionally with their dependencies, build cache, and package files. |
| 32 | |
| 33 | This command will uninstall the specified packages from your workspace. You can control |
| 34 | the removal behavior using various flags. |
| 35 | |
| 36 | Examples: |
| 37 | celer remove boost@1.87.0 # Remove boost package |
| 38 | celer remove boost@1.87.0 -r # Remove boost and its dependencies |
| 39 | celer remove boost@1.87.0 -p # Remove boost and purge package files |
| 40 | celer remove boost@1.87.0 -c # Remove boost and clear build cache |
| 41 | celer remove boost@1.87.0 -d # Remove boost from dev dependencies |
| 42 | celer remove boost@1.87.0 -rpc # Remove with all cleanup options`, |
| 43 | Args: cobra.MinimumNArgs(1), |
| 44 | RunE: func(cmd *cobra.Command, args []string) error { |
| 45 | return r.execute(args) |
| 46 | }, |
| 47 | ValidArgsFunction: r.completion, |
| 48 | } |
| 49 | |
| 50 | // Register flags. |
| 51 | command.Flags().BoolVarP(&r.buildCache, "build-cache", "c", false, "remove build cache along with the package") |
| 52 | command.Flags().BoolVarP(&r.recursive, "recursive", "r", false, "remove package dependencies recursively") |
| 53 | command.Flags().BoolVarP(&r.purge, "purge", "p", false, "purge package files completely") |
| 54 | command.Flags().BoolVarP(&r.dev, "dev", "d", false, "remove from development dependencies") |
| 55 | |
| 56 | // Silence cobra's error and usage output to avoid duplicate messages. |
| 57 | command.SilenceErrors = true |
| 58 | command.SilenceUsage = true |
| 59 | return command |
| 60 | } |
| 61 | |
| 62 | // execute performs the main logic for package removal. |
| 63 | func (r *removeCmd) execute(args []string) error { |