diff options
| -rw-r--r-- | main.go | 2 | ||||
| -rw-r--r-- | print.go | 21 | ||||
| -rw-r--r-- | statistics.go | 13 |
3 files changed, 17 insertions, 19 deletions
@@ -28,7 +28,7 @@ func main() { formula, cask := GetBrewInfo(pkgName) stat := NewStatistics(formula, cask, pkgName) hideLoadingPrompt() - PrintInfo(stat) + stat.Print() return nil }, } @@ -8,29 +8,14 @@ import ( "github.com/hako/durafmt" ) -// === Print Entry Point === // - -func PrintInfo(data *statistics) { - if data == nil { - fmt.Println("Package not found.") - return - } - - printHeader(data) - printUserInteractionSummary(data) - printMetadata(data) - - fmt.Println() -} - // === Main Sections === // -func printHeader(data *statistics) { +func PrintHeader(data *statistics) { printTypeNameAndDesc(data.Type, data.Name, data.Desc) fmt.Println() } -func printUserInteractionSummary(data *statistics) { +func PrintUserInteractionSummary(data *statistics) { a := printInstallDesc( data.Type == "formula", data.InstalledAsDependency, @@ -47,7 +32,7 @@ func printUserInteractionSummary(data *statistics) { } } -func printMetadata(data *statistics) { +func PrintMetadata(data *statistics) { printVersionInfo( data.InstalledVersion, data.Outdated) diff --git a/statistics.go b/statistics.go index 6c7ed88..0cd7d44 100644 --- a/statistics.go +++ b/statistics.go @@ -5,6 +5,7 @@ import ( "path/filepath" "syscall" "time" + "fmt" ) type statistics struct { @@ -73,3 +74,15 @@ func NewStatistics(formula *FormulaInfo, cask *CaskInfo, pkgName string) (*stati return &statObject } + +func (s *statistics) Print() { + if s == nil { + fmt.Println("Package not found.") + return + } + + PrintHeader(s) + PrintUserInteractionSummary(s) + PrintMetadata(s) + fmt.Println() +} |
