github.com/TrueBlocks/trueblocks-core/src/apps/chifra@v0.0.0-20241022031540-b362680128f7/internal/status/handle_diagnose.go (about)

     1  package statusPkg
     2  
     3  import (
     4  	"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/logger"
     5  	"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/output"
     6  	"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types"
     7  )
     8  
     9  func (opts *StatusOptions) HandleDiagnose(rCtx *output.RenderCtx) error {
    10  	testMode := opts.Globals.TestMode
    11  
    12  	fetchData := func(modelChan chan types.Modeler, errorChan chan error) {
    13  		s, err := opts.GetStatus(opts.Diagnose)
    14  		if err != nil {
    15  			errorChan <- err
    16  			return
    17  		}
    18  
    19  		// We want to short circuit the output in the non-json case
    20  		if toTemplate(s, opts.Globals.Writer, testMode, opts.Diagnose, logger.LogTimerOn(), opts.Globals.Format) {
    21  			return
    22  		}
    23  
    24  		modelChan <- s
    25  	}
    26  
    27  	return output.StreamMany(rCtx, fetchData, opts.Globals.OutputOpts())
    28  }