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

RFC: gobrew interactive #145

Closed
kevincobain2000 opened this issue Oct 25, 2023 · 9 comments · Fixed by #147
Closed

RFC: gobrew interactive #145

kevincobain2000 opened this issue Oct 25, 2023 · 9 comments · Fixed by #147
Assignees

Comments

@kevincobain2000
Copy link
Owner

kevincobain2000 commented Oct 25, 2023

RFC

To add interactive behaviour so I don't have to remember commands like gobrew use mod gobrew use latest or even gobrew ls and gobrew ls-remote to check what version I am on etc and etc.

Current situation

On command gobrew, no args, it displays help menu right now.

Proposal

On hitting gobrew, it presents an interactive info as below:

Case 1: Fresh install, from inside a directory with go.mod

$ gobrew
Installed GO version          ...... None
Latest GO version             ...... 1.21.3
Mod GO version                ...... 1.20

Go is not installed, your dir has go.mod file
Do you want to install 1.20 (y/n)

Case 2: Fresh install, from outside a directory with go.mod

$ gobrew
Installed GO version          ...... None
Latest GO version             ...... 1.21.3
Mod GO version                ...... None

Go is not installed
Do you want to install latest Go version 1.21.3 (y/n)

Case 3: Go is installed, but not latest version

$ gobrew
Installed GO version          ...... 1.20
Latest GO version             ...... 1.21.3
Mod GO version                ...... None

Your Go version is not latest
Do you want to install latest Go version 1.21.3 (y/n)

Case 4: Go is installed, but not latest version, but matches mod file

$ gobrew
Installed GO version          ...... 1.20
Latest GO version             ...... 1.21.3
Mod GO version                ...... 1.20

Your Go version and go.mod file matches!
Do you want to install latest Go version 1.21.3 and update mod file (y/n)

Case 5: Go is installed, on latest version, but doesn't match mod file

$ gobrew
Installed GO version          ...... 1.21.3
Latest GO version             ...... 1.21.3
Mod GO version                ...... 1.20

Your Go version and go.mod file doesn't match.
Do you want to update mod file (y/n)
  -> Do you want to downgrade go version (y/n) (if above answer is no)

--

  1. Above can be obtained on hitting gobrew.
    1.1) Additionally, could add --no-interactive y|n option as well. But I don't think that would be necessary at this point.
  2. Or if intractive is too much, then we could consider atleast gobrew info that will only display out info.
@juev
Copy link
Collaborator

juev commented Oct 25, 2023

Hello!

An interesting idea, but I don’t really understand what its essence is yet. Are we trying to provide some logic to the user? We don't have too many teams to get confused about.

According to the given options. The first option is clear, but what if I want to install the latest version of go in the project directory with go.mod?

The second case is not clear to me. If we are outside the directory with the go.mod file, how are we supposed to know to use a certain configuration? If I understand everything correctly, then for the second case the third given option will be used.

There are still too many questions about the logic of work.

@kevincobain2000
Copy link
Owner Author

kevincobain2000 commented Oct 25, 2023

Ah sorry. In Case 2, go.mod version will also be none. I have edited.

@kevincobain2000
Copy link
Owner Author

The purpose of this is that a user will be able to achieve what he wants to achieve just by executing gobrew with no args.

@juev
Copy link
Collaborator

juev commented Oct 26, 2023

I think it looks good.

@kevincobain2000
Copy link
Owner Author

Thanks for checking @juev
I ll work on it.

@gedw99
Copy link
Contributor

gedw99 commented Oct 29, 2023

+1

This will be useful in CI too I think

@kevincobain2000
Copy link
Owner Author

Thanks @gedw99

@gedw99
Copy link
Contributor

gedw99 commented Oct 31, 2023

Was thinking a —output=json would be nice too. Then it’s easy to use in CI and possibly other use cases that are not known yet.

than it possible to parse the json on the call side and react to the output.

maybe layer a golang client that understands the json in a strongly type way too.

basically I realise it’s jsonrpc style with client and server .

there are some great golang libs that do all the grunt work for json rpc out there in GitHub btw.

@kevincobain2000
Copy link
Owner Author

Thanks @gedw99

JSON output could be nice, and I also find hard time finding it's use case.
Only use case I can think of is for the infra/dev-ops/SRE-admin teams, who develop their admin portals inside their companies to just list up some GO versions in a dropdown.
Other than that, I don't know, if JSON output is really necessary and people want to use it on CI with jq

kevincobain2000 added a commit that referenced this issue Nov 1, 2023
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 a pull request may close this issue.

3 participants