Skip to content

Commit 720bad6

Browse files
Improving Console text messages
1 parent ada0c90 commit 720bad6

File tree

1 file changed

+59
-22
lines changed

1 file changed

+59
-22
lines changed

utils/stats/stats.go

Lines changed: 59 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ func (rw *GenericResultsWriter) printTable() error {
268268

269269
t := table.NewWriter()
270270
t.SetOutputMirror(os.Stdout)
271-
t.SetStyle(table.StyleLight)
271+
t.SetStyle(table.StyleDouble)
272272

273273
switch v := rw.data.(type) {
274274
case *ArtifactoryInfo:
@@ -293,6 +293,7 @@ func (rw *GenericResultsWriter) printTable() error {
293293
}
294294
}
295295
t.Render()
296+
log.Output()
296297
return nil
297298
}
298299

@@ -413,6 +414,7 @@ func printRepositoriesSimple(repos *[]RepositoryDetails) {
413414
log.Output("--- Repositories Summary by Type ---")
414415
if len(*repos) == 0 {
415416
log.Output("No Repositories Available")
417+
log.Output()
416418
return
417419
}
418420
counts := getRepositoryCounts(repos)
@@ -437,65 +439,100 @@ func printReleaseBundlesSimple(rbResponse *ReleaseBundleResponse) {
437439
log.Output("--- Available Release Bundles ---")
438440
if len(rbResponse.ReleaseBundles) == 0 {
439441
log.Output("No Release Bundles Available")
442+
log.Output()
440443
return
441444
}
442-
for _, rb := range rbResponse.ReleaseBundles {
443-
log.Output("- ", rb.ReleaseBundleName)
445+
for index, rb := range rbResponse.ReleaseBundles {
446+
log.Output("ReleaseBundle: ", index+1)
447+
log.Output("ReleaseBundleName: ", rb.ReleaseBundleName)
448+
log.Output("RepositoryKey: ", rb.RepositoryKey)
449+
log.Output("ProjectKey:", rb.ProjectKey)
450+
log.Output()
444451
}
445-
log.Output()
446452
}
447453

448454
func printArtifactoryStats(stats *ArtifactoryInfo) {
449455
log.Output("--- Artifactory Statistics Summary ---")
450-
log.Output("Total No of Artifacts: ", stats.BinariesSummary.ArtifactsCount)
456+
log.Output("Total No of Binaries: ", stats.BinariesSummary.BinariesCount)
451457
log.Output("Total Binaries Size: ", stats.BinariesSummary.BinariesSize)
452-
log.Output("Total Storage Used: ", stats.BinariesSummary.ArtifactsSize)
458+
log.Output("Total No of Artifacts: ", stats.BinariesSummary.ArtifactsCount)
459+
log.Output("Total Artifacts Size: ", stats.BinariesSummary.ArtifactsSize)
453460
log.Output("Storage Type: ", stats.FileStoreSummary.StorageType)
454461
log.Output()
455462
}
456463

457464
func printXrayPoliciesStats(policies *[]XrayPolicy) {
458465
log.Output("--- Xray Policies ---")
459-
for _, policy := range *policies {
460-
log.Output("- ", policy.Name)
461-
}
462466
if len(*policies) == 0 {
463467
log.Output("No Xray Policies Available")
468+
log.Output()
469+
return
470+
}
471+
for index, policy := range *policies {
472+
log.Output("Policy: ", index+1)
473+
log.Output("Name: ", policy.Name)
474+
log.Output("Type: ", policy.Type)
475+
log.Output("Author: ", policy.Author)
476+
log.Output("Created: ", policy.Created)
477+
log.Output("Modified: ", policy.Modified)
478+
log.Output()
464479
}
465-
log.Output()
466480
}
467481

468482
func printXrayWatchesStats(watches *[]XrayWatch) {
469483
log.Output("--- Enforced Xray Watches ---")
470-
for _, watch := range *watches {
471-
log.Output("- ", watch.GeneralData.Name)
472-
}
473484
if len(*watches) == 0 {
474485
log.Output("No Xray Watches Available")
486+
log.Output()
487+
return
488+
}
489+
for _, watch := range *watches {
490+
log.Output("Name: ", watch.GeneralData.Name)
491+
for _, resource := range watch.ProjectResources.Resources {
492+
log.Output("Name:", resource.Name)
493+
log.Output("Type:", resource.Type)
494+
log.Output("BinMgrID:", resource.BinMgrID)
495+
}
496+
log.Output("")
475497
}
476-
log.Output()
477498
}
478499

479500
func printProjectsStats(projects *[]Project) {
480501
log.Output("--- Available Projects ---")
481-
for _, project := range *projects {
482-
log.Output("- ", project.DisplayName)
483-
}
484502
if len(*projects) == 0 {
485503
log.Output("No Projects Available")
504+
log.Output()
505+
return
506+
}
507+
for index, project := range *projects {
508+
log.Output("Project: ", index+1)
509+
log.Output("Name: ", project.DisplayName)
510+
log.Output("Key: ", project.ProjectKey)
511+
if project.Description != "" {
512+
log.Output("Description: ", project.Description)
513+
} else {
514+
log.Output("Description: NA")
515+
}
516+
log.Output()
486517
}
487-
log.Output()
488518
}
489519

490520
func printJPDsStats(jpdList *[]JPD) {
491521
log.Output("--- Available JPDs ---")
492-
for _, jpd := range *jpdList {
493-
log.Output("- ", jpd.Name)
494-
}
495522
if len(*jpdList) == 0 {
496523
log.Output("No JPDs Info Available")
524+
log.Output()
525+
return
526+
}
527+
for index, jpd := range *jpdList {
528+
log.Output("JPD: ", index+1)
529+
log.Output("Name: ", jpd.Name)
530+
log.Output("URL: ", jpd.URL)
531+
log.Output("Status: ", jpd.Status.Code)
532+
log.Output("Detailed Status: ", jpd.Status.Message)
533+
log.Output("Local: ", jpd.Local)
534+
log.Output()
497535
}
498-
log.Output()
499536
}
500537

501538
func printErrorMessage(apiError *clientStats.APIError) {

0 commit comments

Comments
 (0)