@@ -537,7 +537,7 @@ name is specified then all services are queried.`,
537537 for {
538538 var viewServicesSummary = config.ServicesSummaries {}
539539
540- if strings . Contains ( OutputFormat , constants . JSONPATH ) || OutputFormat == constants . JSON {
540+ if isJSONPathOrJSON () {
541541 data , err := dataFetcher .GetViewsSummaryJSONAllServices ()
542542 if err != nil {
543543 return err
@@ -621,7 +621,6 @@ func getCacheDetails(cmd *cobra.Command, args []string, displayType string) erro
621621 cacheResult []byte
622622 cacheDetails = config.CacheDetails {}
623623 cachePartitionDetails = config.CachePartitionDetails {}
624- result string
625624 )
626625
627626 if displayType == partitionDisplayType {
@@ -637,41 +636,35 @@ func getCacheDetails(cmd *cobra.Command, args []string, displayType string) erro
637636 return fmt .Errorf (cannotFindCache , cacheName , serviceName )
638637 }
639638
640- if strings .Contains (OutputFormat , constants .JSONPATH ) {
641- result , err = utils .GetJSONPathResults (cacheResult , OutputFormat )
642- if err != nil {
643- return err
644- }
645- cmd .Println (result )
646- } else if OutputFormat == constants .JSON {
647- cmd .Println (string (cacheResult ))
639+ if isJSONPathOrJSON () {
640+ return processJSONOutput (cmd , cacheResult )
641+ }
642+
643+ if displayType == partitionDisplayType {
644+ err = json .Unmarshal (cacheResult , & cachePartitionDetails )
648645 } else {
649- if displayType == partitionDisplayType {
650- err = json .Unmarshal (cacheResult , & cachePartitionDetails )
651- } else {
652- err = json .Unmarshal (cacheResult , & cacheDetails )
653- }
654- if err != nil {
655- return utils .GetError ("unable to unmarshall cache result" , err )
656- }
646+ err = json .Unmarshal (cacheResult , & cacheDetails )
647+ }
648+ if err != nil {
649+ return utils .GetError ("unable to unmarshall cache result" , err )
650+ }
657651
658- printWatchHeader (cmd )
659- cmd .Println (FormatCurrentCluster (connection ))
652+ printWatchHeader (cmd )
653+ cmd .Println (FormatCurrentCluster (connection ))
660654
661- if displayType != partitionDisplayType {
662- cmd .Printf ("Cache: %s\n \n " , args [0 ])
663- }
655+ if displayType != partitionDisplayType {
656+ cmd .Printf ("Cache: %s\n \n " , args [0 ])
657+ }
664658
665- if displayType == access {
666- cmd .Println (FormatCacheDetailsSizeAndAccess (cacheDetails .Details ))
667- } else if displayType == "index" {
668- cmd .Println (FormatCacheIndexDetails (cacheDetails .Details ))
669- } else if displayType == storage {
670- cmd .Println (FormatCacheDetailsStorage (cacheDetails .Details ))
671- } else if displayType == partitionDisplayType {
672- cmd .Printf ("Cache: %s\n " , args [0 ])
673- cmd .Println (FormatCachePartitions (cachePartitionDetails .Details , cacheSummary ))
674- }
659+ if displayType == access {
660+ cmd .Println (FormatCacheDetailsSizeAndAccess (cacheDetails .Details ))
661+ } else if displayType == "index" {
662+ cmd .Println (FormatCacheIndexDetails (cacheDetails .Details ))
663+ } else if displayType == storage {
664+ cmd .Println (FormatCacheDetailsStorage (cacheDetails .Details ))
665+ } else if displayType == partitionDisplayType {
666+ cmd .Printf ("Cache: %s\n " , args [0 ])
667+ cmd .Println (FormatCachePartitions (cachePartitionDetails .Details , cacheSummary ))
675668 }
676669
677670 // check to see if we should exit if we are not watching
0 commit comments