Skip to content

Use feedback/result structs in cli commands instead of rpc ones #2389

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

Merged
merged 24 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
a33072e
added more mapper in feedback result pkg
alessio-perugini Oct 25, 2023
e639e5b
cli: outdated command use feedback result structs
alessio-perugini Oct 25, 2023
cbe3b0d
cli: upload use feedback result structs
alessio-perugini Oct 25, 2023
3ae9dee
cli: board details use feedback result structs
alessio-perugini Oct 25, 2023
da7541a
rename result Platform in PlatformSummary
alessio-perugini Oct 25, 2023
3aee471
fixup mapper BoardListAllRespnse
alessio-perugini Oct 25, 2023
dcf7f86
cli: board listall use feedback result structs
alessio-perugini Oct 25, 2023
cdc80bf
cli: board search use feedback result structs
alessio-perugini Oct 25, 2023
60abc6a
cli: board list use feedback result structs
alessio-perugini Oct 25, 2023
1534ab9
cli: lib deps use feedback result structs
alessio-perugini Oct 25, 2023
5fd4539
cli: lib search use feedback result structs
alessio-perugini Oct 25, 2023
c93f4bc
cli: lib examples use feedback result structs
alessio-perugini Oct 25, 2023
e18ec5f
cli: lib list use feedback result structs
alessio-perugini Oct 25, 2023
ce31a9b
cli: monitor use feedback result structs
alessio-perugini Oct 25, 2023
429f525
cli: compile use feedback result structs
alessio-perugini Oct 25, 2023
a16ba4d
add tests
alessio-perugini Oct 26, 2023
e619093
fix typo and import name
alessio-perugini Nov 6, 2023
2e16184
remove redundant nil checks
alessio-perugini Nov 6, 2023
0702b77
fix printing empty string instead of empty table
alessio-perugini Nov 6, 2023
90cb43a
fix: make anonymous struct explicit
alessio-perugini Nov 6, 2023
2d77b39
fix: use rpc enum String method
alessio-perugini Nov 6, 2023
a126e93
add BoardListWatchResponse mapper
alessio-perugini Nov 6, 2023
0aabc1b
fix: remap rpc enums
alessio-perugini Nov 6, 2023
1d855a0
fix: cli sketch new - not showing any json output
alessio-perugini Nov 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
rename result Platform in PlatformSummary
  • Loading branch information
alessio-perugini committed Oct 26, 2023
commit da7541a65aacdfeedc91f6cdf92dea96f6b58433
4 changes: 2 additions & 2 deletions internal/cli/core/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,13 @@ func GetList(inst *rpc.Instance, all bool, updatableOnly bool) []*rpc.PlatformSu
func newCoreListResult(in []*rpc.PlatformSummary) *coreListResult {
res := &coreListResult{}
for _, platformSummary := range in {
res.platforms = append(res.platforms, result.NewPlatformResult(platformSummary))
res.platforms = append(res.platforms, result.NewPlatformSummary(platformSummary))
}
return res
}

type coreListResult struct {
platforms []*result.Platform
platforms []*result.PlatformSummary
}

// Data implements Result interface
Expand Down
4 changes: 2 additions & 2 deletions internal/cli/core/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ func runSearchCommand(cmd *cobra.Command, args []string) {
// output from this command requires special formatting, let's create a dedicated
// feedback.Result implementation
type searchResults struct {
platforms []*result.Platform
platforms []*result.PlatformSummary
}

func newSearchResult(in []*rpc.PlatformSummary) *searchResults {
res := &searchResults{}
for _, platformSummary := range in {
res.platforms = append(res.platforms, result.NewPlatformResult(platformSummary))
res.platforms = append(res.platforms, result.NewPlatformSummary(platformSummary))
}
return res
}
Expand Down
14 changes: 7 additions & 7 deletions internal/cli/feedback/result/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ import (
semver "go.bug.st/relaxed-semver"
)

// NewPlatformResult creates a new result.Platform from rpc.PlatformSummary
func NewPlatformResult(in *rpc.PlatformSummary) *Platform {
// NewPlatformSummary creates a new result.Platform from rpc.PlatformSummary
func NewPlatformSummary(in *rpc.PlatformSummary) *PlatformSummary {
releases := orderedmap.NewWithConversionFunc[*semver.Version, *PlatformRelease, string]((*semver.Version).String)
for k, v := range in.Releases {
releases.Set(semver.MustParse(k), NewPlatformReleaseResult(v))
}
releases.SortKeys((*semver.Version).CompareTo)

return &Platform{
return &PlatformSummary{
Id: in.Metadata.Id,
Maintainer: in.Metadata.Maintainer,
Website: in.Metadata.Website,
Expand All @@ -45,8 +45,8 @@ func NewPlatformResult(in *rpc.PlatformSummary) *Platform {
}
}

// Platform maps a rpc.Platform
type Platform struct {
// PlatformSummary maps a rpc.PlatformSummary
type PlatformSummary struct {
Id string `json:"id,omitempty"`
Maintainer string `json:"maintainer,omitempty"`
Website string `json:"website,omitempty"`
Expand All @@ -62,12 +62,12 @@ type Platform struct {
}

// GetLatestRelease returns the latest relase of this platform or nil if none available.
func (p *Platform) GetLatestRelease() *PlatformRelease {
func (p *PlatformSummary) GetLatestRelease() *PlatformRelease {
return p.Releases.Get(p.LatestVersion)
}

// GetInstalledRelease returns the installed relase of this platform or nil if none available.
func (p *Platform) GetInstalledRelease() *PlatformRelease {
func (p *PlatformSummary) GetInstalledRelease() *PlatformRelease {
return p.Releases.Get(p.InstalledVersion)
}

Expand Down
6 changes: 3 additions & 3 deletions internal/cli/outdated/outdated.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,17 @@ func Outdated(inst *rpc.Instance) {
// output from this command requires special formatting, let's create a dedicated
// feedback.Result implementation
type outdatedResult struct {
Platforms []*result.Platform `json:"platforms,omitempty"`
Platforms []*result.PlatformSummary `json:"platforms,omitempty"`
InstalledLibs []*result.InstalledLibrary `json:"libraries,omitempty"`
}

func newOutdatedResult(inPlatforms []*rpc.PlatformSummary, inLibraries []*rpc.InstalledLibrary) *outdatedResult {
res := &outdatedResult{
Platforms: make([]*result.Platform, len(inPlatforms)),
Platforms: make([]*result.PlatformSummary, len(inPlatforms)),
InstalledLibs: make([]*result.InstalledLibrary, len(inLibraries)),
}
for i, v := range inPlatforms {
res.Platforms[i] = result.NewPlatformResult(v)
res.Platforms[i] = result.NewPlatformSummary(v)
}
for i, v := range inLibraries {
res.InstalledLibs[i] = result.NewInstalledLibraryResult(v)
Expand Down