From 7df34aa7a40be0d7b759ea3ef42cedf9f25f32b2 Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Tue, 10 Jan 2023 21:36:03 +0100 Subject: commands: add a nice terminal progress bar when building the cache One issue remaining is that writing the cache takes significant time, but I don't know how to reflect that nicely to the user. --- entities/identity/identity.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'entities') diff --git a/entities/identity/identity.go b/entities/identity/identity.go index 22ce652c..e654cb2b 100644 --- a/entities/identity/identity.go +++ b/entities/identity/identity.go @@ -238,6 +238,9 @@ func readAll(repo repository.ClockedRepo, refPrefix string) <-chan entity.Stream return } + total := int64(len(refs)) + current := int64(1) + for _, ref := range refs { i, err := read(repo, ref) @@ -246,7 +249,12 @@ func readAll(repo repository.ClockedRepo, refPrefix string) <-chan entity.Stream return } - out <- entity.StreamedEntity[*Identity]{Entity: i} + out <- entity.StreamedEntity[*Identity]{ + Entity: i, + CurrentEntity: current, + TotalEntities: total, + } + current++ } }() -- cgit