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

     1  package slurpPkg
     2  
     3  import (
     4  	"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/output"
     5  	"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types"
     6  )
     7  
     8  func (opts *SlurpOptions) HandleAppearances(rCtx *output.RenderCtx) error {
     9  	provider, err := opts.Provider()
    10  	if err != nil {
    11  		return err
    12  	}
    13  	provider.SetPrintProgress(opts.Globals.ShowProgress())
    14  
    15  	fetchData := func(modelChan chan types.Modeler, errorChan chan error) {
    16  		appearancesChan := provider.Appearances(rCtx.Ctx, opts.Query(), errorChan)
    17  		for appearance := range appearancesChan {
    18  			modelChan <- &appearance
    19  		}
    20  	}
    21  
    22  	return output.StreamMany(rCtx, fetchData, opts.Globals.OutputOpts())
    23  }