warrensbox/terraform-switcher

Natural sorting is required for newer versions to be listed as "recent"

Closed this issue · 3 comments

As of today, 0.14.9 is marked as recent, while 0.14.10 is not. I'm guessing this is because the version numbers are sorted using standard sort instead of a natural sorting algorithm.

@skyzyx
Hey Ryan, what command are you running:
When I run tfswitch --latest-stable 0.14, I see:
Screen Shot 2021-04-14 at 9 16 53 AM

When I run tfswitch --latest, I see:
Screen Shot 2021-04-14 at 9 16 15 AM

When I run tfswitch, I see 14.10 at the top:
Screen Shot 2021-04-14 at 9 14 20 AM

Can you post a screenshot of what you're seeing?

When I posted this, I was seeing 0.14.9 marked as *recent, but 0.14.10 was not marked this way, and was lower in the list.

Perhaps I don't understand the recency algorithm?

This is what I see this morning, after 0.15.0 has been released.

Screen Shot 2021-04-14 at 9 43 14 AM

@skyzyx the *recent here means that that's the most recent version that you have used on your machine. In this case, it means - you have "recently" used version 0.14.10 (this does not mean this is the latest version released by Hashicorp).
tfswitch remember the last 3 recent version that you have used. That way, it's easy to switch instead of scrolling all the way down.

For example : (the order of switching to different terraform version using tfswitch)
Project 1 : terraform 0.14.8 -> Project 2 : terraform 0.14.9 -> Project 3 : terraform 0.11.13 -> Project 4 :terraform 0.10.08

The dropdown should show:
0.10.08 *recent
0.11.13 *recent
0.14.9 *recent
Since these are the 3 last recent version that was used.