/
dependencies.go
42 lines (38 loc) · 1.1 KB
/
dependencies.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package cmd
import (
"github.com/fdaines/spm-go/cmd/impl"
"github.com/fdaines/spm-go/utils"
"github.com/fdaines/spm-go/utils/output"
pkg "github.com/fdaines/spm-go/utils/packages"
"github.com/spf13/cobra"
)
var (
dependenciesCmd = &cobra.Command{
Use: "dependencies",
Short: "Lists dependencies of each package",
Args: ValidateArgs,
Run: listPackagesDependencies,
}
)
func init() {
rootCmd.AddCommand(dependenciesCmd)
}
func listPackagesDependencies(cmd *cobra.Command, args []string) {
utils.ExecuteWithTimer(func() {
utils.PrintMessage("Dependencies analysis started.")
mainPackage, err := pkg.GetMainPackage()
if err != nil {
utils.PrintError("Error loading main package", err)
return
}
pkgsInfo := pkg.GetBasicPackagesInfo()
utils.PrintMessage("Gathering package metrics, please wait until the command is finished running.")
for index, _ := range pkgsInfo {
utils.PrintStep()
impl.FillDependencies(pkgsInfo[index], pkgsInfo)
}
utils.PrintVerboseMessage("Done.")
printDependencies(pkgsInfo)
output.GenerateHtmlOutput(pkgsInfo, mainPackage, "dependencies")
})
}