| 32 | } |
| 33 | |
| 34 | func (t *treeCmd) Command(celer *configs.Celer) *cobra.Command { |
| 35 | t.celer = celer |
| 36 | command := &cobra.Command{ |
| 37 | Use: "tree", |
| 38 | Short: "Show the dependency tree of a package or project.", |
| 39 | Long: `Show the dependency tree of a package or project. |
| 40 | |
| 41 | This command shows a hierarchical view of all dependencies for a given |
| 42 | package or project, including both regular and development dependencies. |
| 43 | It also performs dependency validation including circular dependency checks |
| 44 | and version conflict detection. |
| 45 | |
| 46 | Examples: |
| 47 | celer tree boost@1.87.0 # Show dependencies for a specific package |
| 48 | celer tree my_project # Show dependencies for a project |
| 49 | celer tree opencv@4.11.0 --hide-dev # Hide development dependencies`, |
| 50 | Args: cobra.ExactArgs(1), |
| 51 | RunE: func(cmd *cobra.Command, args []string) error { |
| 52 | return t.tree(args[0]) |
| 53 | }, |
| 54 | ValidArgsFunction: t.completion, |
| 55 | } |
| 56 | |
| 57 | // Register flags. |
| 58 | command.Flags().BoolVar(&t.hideDevDep, "hide-dev", false, "hide dev dep in dependencies tree.") |
| 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 | |
| 66 | func (t *treeCmd) tree(target string) error { |
| 67 | // Initialize celer. |