Skip to content

Conversation

@NucleoFusion
Copy link

Fixes #951

Changes

  • adds a --show-elapsed flag that shows elapsed time.
image image
	return fmt.Sprintf("(%dd %dh %dm)", days, hours, minutes)
	
	return fmt.Sprintf("(%dh %dm)", hours, minutes)
	
	return fmt.Sprintf("(%dm %ds)", minutes, seconds)

	return fmt.Sprintf("(%ds)", seconds)

These are the formats

@NucleoFusion NucleoFusion requested a review from a team as a code owner August 22, 2025 12:39
@NucleoFusion NucleoFusion requested review from andreynering and raphamorim and removed request for a team August 22, 2025 12:39
return fmt.Sprintf("(%dm %ds)", minutes, seconds)
}
return fmt.Sprintf("(%ds)", seconds)
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this provide enough additional value over plain Sprintf? 🤔

fmt.Sprintf("duration: %s", d)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean showing only the seconds? or formatting time.Now()?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I mean formatting the duration. I realize we should round, but this:

var start = time.Now()
for true {
  time.Sleep(100 * time.Millisecond)
  fmt.Printf("%s\n", time.Since(start).Round(100*time.Millisecond))
}

creates output like

59.6s
59.7s
59.9s
1m0s
1m0.1s
1m0.2s
1m0.3s

Which is basically what you propose, sans the spaces. Hence my question, if you think the visual difference justifies the additional code.

(Not my call, just a thought.)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was not aware of this format specifier.
I would say since Gum is reliant on being User Friendly and good looking.
a 10 line function would justify it. I could make the formatting better too, if you have something in mind.
Its up to you though. So let me know and Ill change it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gum spin displays expired time

2 participants