-
Notifications
You must be signed in to change notification settings - Fork 3
feat: add daemon command and gRPC list support
#46
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
base: main
Are you sure you want to change the base?
Conversation
dc206b4 to
ba718f5
Compare
service/service_list.go
Outdated
| latest := false | ||
| if manifest.Releases[i].Version == manifest.Latest.Version { | ||
| latest = true | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| latest := false | |
| if manifest.Releases[i].Version == manifest.Latest.Version { | |
| latest = true | |
| } | |
| latest := (manifest.Releases[i].Version == manifest.Latest.Version) |
Also, it's unclear why you're looping in reverse here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The json manifest we get contains the latest release in the last element of the array, but we decided that we want to return it as the first item of Releases
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not depend on how the input data is sorted; it happens to be that way, but it is not guaranteed.
Co-authored-by: Cristian Maglie <c.maglie@bug.st>
974c302 to
d3b72e1
Compare
| protoc:compile: | ||
| desc: Compile protobuf definitions | ||
| cmds: | ||
| - buf dep update |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would install buf as a go tool. You can run go get --tool github.com/bufbuild/buf to add the latest buf version in the go.mod, and then here you can write
| - buf dep update | |
| - go tool buf dep update |
|
|
||
| daemonCommand.Flags().StringVar(&daemonPort, | ||
| "port", "50052", | ||
| i18n.Tr("The TCP port the daemon will listen to")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| i18n.Tr("The TCP port the daemon will listen to")) | |
| i18n.Tr("The TCP port the daemon will listen to, 0 for random port")) |
| "github.com/arduino/arduino-flasher-cli/cmd/feedback" | ||
| "github.com/arduino/arduino-flasher-cli/cmd/i18n" | ||
|
|
||
| flasher "github.com/arduino/arduino-flasher-cli/rpc/cc/arduino/flasher/v1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| "github.com/arduino/arduino-flasher-cli/cmd/feedback" | |
| "github.com/arduino/arduino-flasher-cli/cmd/i18n" | |
| flasher "github.com/arduino/arduino-flasher-cli/rpc/cc/arduino/flasher/v1" | |
| "github.com/arduino/arduino-flasher-cli/cmd/feedback" | |
| "github.com/arduino/arduino-flasher-cli/cmd/i18n" | |
| flasher "github.com/arduino/arduino-flasher-cli/rpc/cc/arduino/flasher/v1" |
| } | ||
|
|
||
| daemonCommand.Flags().StringVar(&daemonPort, | ||
| "port", "50052", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would use a random port by default
| "port", "50052", | |
| "port", "0", |
| latest := false | ||
| if manifest.Releases[i].Version == manifest.Latest.Version { | ||
| latest = true | ||
| } | ||
| resp.Releases = append(resp.Releases, &flasher.Release{BuildId: manifest.Releases[i].Version, Latest: latest}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cannot this be simplified in the following?
| latest := false | |
| if manifest.Releases[i].Version == manifest.Latest.Version { | |
| latest = true | |
| } | |
| resp.Releases = append(resp.Releases, &flasher.Release{BuildId: manifest.Releases[i].Version, Latest: latest}) | |
| resp.Releases = append(resp.Releases, &flasher.Release{ | |
| BuildId: manifest.Releases[i].Version, | |
| Latest: manifest.Releases[i].Version == manifest.Latest.Version | |
| }) |
| list.NewListCmd(), | ||
| download.NewDownloadCmd(), | ||
| version.NewVersionCmd(Version), | ||
| daemon.NewDaemonCommand(srv), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| daemon.NewDaemonCommand(srv), | |
| daemon.NewDaemonCommand(service.NewFlasherServer()), |
| srv := service.NewFlasherServer() | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| srv := service.NewFlasherServer() |
|
|
||
| func (r daemonResult) String() string { | ||
| j, _ := json.Marshal(r) | ||
| return fmt.Sprintln(i18n.Tr("Daemon is now listening on %s:%s", r.IP, r.Port)) + fmt.Sprintln(string(j)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you including the JSON?
| return fmt.Sprintln(i18n.Tr("Daemon is now listening on %s:%s", r.IP, r.Port)) + fmt.Sprintln(string(j)) | |
| return fmt.Sprintln(i18n.Tr("Daemon is now listening on %s:%s", r.IP, r.Port)) |
Motivation
Add gRPC
daemonsupport for thelistfunction.Change description
Add gRPC
daemonsupport for thelistfunction.Additional Notes
It can be tested following these steps:
Reviewer checklist
main.