MCPcopy Create free account
hub / github.com/celer-pkg/celer / Command

Method Command

cmds/cmd_autoremove.go:27–64  ·  view source on GitHub ↗
(celer *configs.Celer)

Source from the content-addressed store, hash-verified

25}
26
27func (a *autoremoveCmd) Command(celer *configs.Celer) *cobra.Command {
28 a.celer = celer
29 command := &cobra.Command{
30 Use: "autoremove",
31 Short: "Remove libraries that do not belong to current project.",
32 Long: `Remove libraries that do not belong to current project.
33
34This command scans installed runtime and buildtime packages, compares them
35against the dependency graph required by the current project, and removes
36packages that are no longer needed.
37
38Use --purge to also remove cached package archives, and --build-cache to
39remove build cache together with removed packages.
40
41Examples:
42 celer autoremove # Remove unused installed packages
43 celer autoremove --purge # Also remove package archives
44 celer autoremove --build-cache # Also remove build cache
45 celer autoremove --purge --build-cache # Remove packages, archives, and build cache`,
46 Args: cobra.NoArgs,
47 RunE: func(cmd *cobra.Command, args []string) error {
48 if err := a.celer.Init(); err != nil {
49 return fmt.Errorf("failed to init celer -> %w", err)
50 }
51
52 return a.autoremove()
53 },
54 ValidArgsFunction: a.completion,
55 }
56
57 command.Flags().BoolVarP(&a.buildCache, "build-cache", "c", false, "autoremove packages along with build cache.")
58 command.Flags().BoolVarP(&a.purge, "purge", "p", false, "autoremove packages along with its package file.")
59
60 // Silence cobra's error and usage output to avoid duplicate messages.
61 command.SilenceErrors = true
62 command.SilenceUsage = true
63 return command
64}
65
66func (a *autoremoveCmd) autoremove() error {
67 // Reset collected state for every run.

Callers 2

Calls 2

autoremoveMethod · 0.95
InitMethod · 0.65

Tested by 2