Skip to content

Commit a3d9b70

Browse files
committed
Made utility functions private and put them in their own file
1 parent 8d3dafa commit a3d9b70

14 files changed

+22
-22
lines changed

Diff for: commands/service_board_listall.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ func (s *arduinoCoreServerImpl) BoardListAll(ctx context.Context, req *rpc.Board
4646
}
4747

4848
rpcPlatform := &rpc.Platform{
49-
Metadata: PlatformToRPCPlatformMetadata(platform),
50-
Release: PlatformReleaseToRPC(installedPlatformRelease),
49+
Metadata: platformToRPCPlatformMetadata(platform),
50+
Release: platformReleaseToRPC(installedPlatformRelease),
5151
}
5252

5353
toTest := []string{

Diff for: commands/service_board_search.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ func (s *arduinoCoreServerImpl) BoardSearch(ctx context.Context, req *rpc.BoardS
6767
Fqbn: board.FQBN(),
6868
IsHidden: board.IsHidden(),
6969
Platform: &rpc.Platform{
70-
Metadata: PlatformToRPCPlatformMetadata(platform),
71-
Release: PlatformReleaseToRPC(installedPlatformRelease),
70+
Metadata: platformToRPCPlatformMetadata(platform),
71+
Release: platformReleaseToRPC(installedPlatformRelease),
7272
},
7373
})
7474
}
@@ -82,8 +82,8 @@ func (s *arduinoCoreServerImpl) BoardSearch(ctx context.Context, req *rpc.BoardS
8282
foundBoards = append(foundBoards, &rpc.BoardListItem{
8383
Name: strings.Trim(board.Name, " \n"),
8484
Platform: &rpc.Platform{
85-
Metadata: PlatformToRPCPlatformMetadata(platform),
86-
Release: PlatformReleaseToRPC(latestPlatformRelease),
85+
Metadata: platformToRPCPlatformMetadata(platform),
86+
Release: platformReleaseToRPC(latestPlatformRelease),
8787
},
8888
})
8989
}

Diff for: commands/service_library_download.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func (s *arduinoCoreServerImpl) LibraryDownload(req *rpc.LibraryDownloadRequest,
5656
return err
5757
}
5858

59-
version, err := ParseVersion(req.GetVersion())
59+
version, err := parseVersion(req.GetVersion())
6060
if err != nil {
6161
return err
6262
}

Diff for: commands/service_library_install.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ func (s *arduinoCoreServerImpl) LibraryInstall(req *rpc.LibraryInstallRequest, s
109109
libReleasesToInstall := map[*librariesindex.Release]*librariesmanager.LibraryInstallPlan{}
110110
installLocation := libraries.FromRPCLibraryInstallLocation(req.GetInstallLocation())
111111
for _, lib := range toInstall {
112-
version, err := ParseVersion(lib.GetVersionRequired())
112+
version, err := parseVersion(lib.GetVersionRequired())
113113
if err != nil {
114114
return err
115115
}

Diff for: commands/service_library_resolve_deps.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func (s *arduinoCoreServerImpl) LibraryResolveDependencies(ctx context.Context,
4747

4848
func libraryResolveDependencies(lme *librariesmanager.Explorer, li *librariesindex.Index,
4949
reqName, reqVersion string, noOverwrite bool) (*rpc.LibraryResolveDependenciesResponse, error) {
50-
version, err := ParseVersion(reqVersion)
50+
version, err := parseVersion(reqVersion)
5151
if err != nil {
5252
return nil, err
5353
}

Diff for: commands/service_library_uninstall.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func (s *arduinoCoreServerImpl) LibraryUninstall(req *rpc.LibraryUninstallReques
4747
return err
4848
}
4949

50-
version, err := ParseVersion(req.GetVersion())
50+
version, err := parseVersion(req.GetVersion())
5151
if err != nil {
5252
return err
5353
}

Diff for: commands/service_platform_download.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func (s *arduinoCoreServerImpl) PlatformDownload(req *rpc.PlatformDownloadReques
4848
}
4949
defer release()
5050

51-
version, err := ParseVersion(req.GetVersion())
51+
version, err := parseVersion(req.GetVersion())
5252
if err != nil {
5353
return &cmderrors.InvalidVersionError{Cause: err}
5454
}

Diff for: commands/service_platform_install.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func (s *arduinoCoreServerImpl) PlatformInstall(req *rpc.PlatformInstallRequest,
5353
}
5454
defer release()
5555

56-
version, err := ParseVersion(req.GetVersion())
56+
version, err := parseVersion(req.GetVersion())
5757
if err != nil {
5858
return &cmderrors.InvalidVersionError{Cause: err}
5959
}

Diff for: commands/service_platform_search.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func (s *arduinoCoreServerImpl) PlatformSearch(_ context.Context, req *rpc.Platf
8282
out := []*rpc.PlatformSummary{}
8383
for _, platform := range res {
8484
rpcPlatformSummary := &rpc.PlatformSummary{
85-
Metadata: PlatformToRPCPlatformMetadata(platform),
85+
Metadata: platformToRPCPlatformMetadata(platform),
8686
Releases: map[string]*rpc.PlatformRelease{},
8787
}
8888
if installed := pme.GetInstalledPlatformRelease(platform); installed != nil {
@@ -92,7 +92,7 @@ func (s *arduinoCoreServerImpl) PlatformSearch(_ context.Context, req *rpc.Platf
9292
rpcPlatformSummary.LatestVersion = latestCompatible.Version.String()
9393
}
9494
for _, platformRelease := range platform.GetAllReleases() {
95-
rpcPlatformRelease := PlatformReleaseToRPC(platformRelease)
95+
rpcPlatformRelease := platformReleaseToRPC(platformRelease)
9696
rpcPlatformSummary.Releases[rpcPlatformRelease.GetVersion()] = rpcPlatformRelease
9797
}
9898
out = append(out, rpcPlatformSummary)

Diff for: commands/service_platform_upgrade.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ func (s *arduinoCoreServerImpl) PlatformUpgrade(req *rpc.PlatformUpgradeRequest,
7676
if platformRelease != nil {
7777
syncSend.Send(&rpc.PlatformUpgradeResponse{
7878
Platform: &rpc.Platform{
79-
Metadata: PlatformToRPCPlatformMetadata(platformRelease.Platform),
80-
Release: PlatformReleaseToRPC(platformRelease),
79+
Metadata: platformToRPCPlatformMetadata(platformRelease.Platform),
80+
Release: platformReleaseToRPC(platformRelease),
8181
},
8282
})
8383
}

Diff for: commands/core.go renamed to commands/utility_core.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ import (
2020
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
2121
)
2222

23-
// PlatformToRPCPlatformMetadata converts our internal structure to the RPC structure.
24-
func PlatformToRPCPlatformMetadata(platform *cores.Platform) *rpc.PlatformMetadata {
23+
// platformToRPCPlatformMetadata converts our internal structure to the RPC structure.
24+
func platformToRPCPlatformMetadata(platform *cores.Platform) *rpc.PlatformMetadata {
2525
return &rpc.PlatformMetadata{
2626
Id: platform.String(),
2727
Maintainer: platform.Package.Maintainer,
@@ -33,10 +33,10 @@ func PlatformToRPCPlatformMetadata(platform *cores.Platform) *rpc.PlatformMetada
3333
}
3434
}
3535

36-
// PlatformReleaseToRPC converts our internal structure to the RPC structure.
36+
// platformReleaseToRPC converts our internal structure to the RPC structure.
3737
// Note: this function does not touch the "Installed" field of rpc.Platform as it's not always clear that the
3838
// platformRelease we're currently converting is actually installed.
39-
func PlatformReleaseToRPC(platformRelease *cores.PlatformRelease) *rpc.PlatformRelease {
39+
func platformReleaseToRPC(platformRelease *cores.PlatformRelease) *rpc.PlatformRelease {
4040
// If the boards are not installed yet, the `platformRelease.Boards` will be a zero length slice.
4141
// In such case, we have to use the `platformRelease.BoardsManifest` instead.
4242
// So that we can retrieve the name of the boards at least.
File renamed without changes.

Diff for: commands/version.go renamed to commands/utility_version.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ import (
2020
semver "go.bug.st/relaxed-semver"
2121
)
2222

23-
// ParseVersion returns the parsed version or nil if the version is
23+
// parseVersion returns the parsed version or nil if the version is
2424
// the empty string. An error is returned if the version is not valid
2525
// semver.
26-
func ParseVersion(version string) (*semver.Version, error) {
26+
func parseVersion(version string) (*semver.Version, error) {
2727
if version == "" {
2828
return nil, nil
2929
}

0 commit comments

Comments
 (0)