Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: If no version number provided, provide a prompt to show available sdk version #205

Closed
bytemain opened this issue Apr 15, 2024 · 3 comments · Fixed by #236
Closed
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers
Milestone

Comments

@bytemain
Copy link
Member

bytemain commented Apr 15, 2024

1. Your usage scenarios?

install golang by:

~ vfox install golang
plugin [PreInstall] method error: no version number provided

and we can provide a prompt:

➜  ~ vfox install golang
> no version number provided, do you want to search available versions and install it? (y/n)
y
Please select a version of golang [type to search]: 
->  v1.22.1 (stable)
   v1.21.8 (stable)
   v1.22.0
   v1.21.7
   v1.21.6
   v1.21.5
   v1.21.4
   v1.21.3
   v1.21.2
   v1.21.1
   v1.21.0
   v1.22rc2
   v1.22rc1
   v1.21rc4
   v1.21rc3
   v1.21rc2
Press ↑/↓ to select and press ←/→ to page, and press Enter to confirm

close: version-fox/vfox-nodejs#8

2. What is your expected outcome?

@aooohan
Copy link
Member

aooohan commented Apr 28, 2024

image

It doesn't seem to have really been fixed.

@aooohan
Copy link
Member

aooohan commented Apr 28, 2024

I see that it is the existence of the version returned by the PreInstall that determines whether or not to display the available list. But it's possible that PreInstall has already thrown an error.

err = source.Install(version)
if errors.Is(err, internal.ErrNoVersionProvided) {
showAvailable, _ := pterm.DefaultInteractiveConfirm.Show(fmt.Sprintf("No %s version provided, do you want to select a version to install?", name))
if showAvailable {

vfox/internal/interfaces.go

Lines 112 to 114 in 350e67a

if i.Version == "" {
return nil, ErrNoVersionProvided
}

For example, erlang plugin:

https://github.com/version-fox/vfox-erlang/blob/afa9f2cc5e00788894bf51bb7cac9fcb71c444bc/hooks/pre_install.lua#L13-L16

@aooohan
Copy link
Member

aooohan commented Apr 28, 2024

I now think it might be better to solve it in the following two ways:

  1. If no version provided, we will pass latest as version to the plugin, and we must ask the plugin to implement the meaning of latest.
  2. We still treat it as the latest and use the version first result from search. But we must ask the plugin to sort the Available results in descending order.

@aooohan aooohan added this to the 0.4.2 milestone Apr 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants