Skip to content

Commit a71a378

Browse files
committed
Inlining methods in ArduinoCoreServiceImpl (part 2)
Added the calls to: * BoardDetails
1 parent a510d2d commit a71a378

File tree

9 files changed

+26
-29
lines changed

9 files changed

+26
-29
lines changed

Diff for: commands/service.go

-5
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,6 @@ type arduinoCoreServerImpl struct {
4242
versionString string
4343
}
4444

45-
// BoardDetails FIXMEDOC
46-
func (s *arduinoCoreServerImpl) BoardDetails(ctx context.Context, req *rpc.BoardDetailsRequest) (*rpc.BoardDetailsResponse, error) {
47-
return BoardDetails(ctx, req)
48-
}
49-
5045
// BoardList FIXMEDOC
5146
func (s *arduinoCoreServerImpl) BoardList(ctx context.Context, req *rpc.BoardListRequest) (*rpc.BoardListResponse, error) {
5247
ports, _, err := BoardList(req)

Diff for: commands/service_board_details.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727

2828
// BoardDetails returns all details for a board including tools and HW identifiers.
2929
// This command basically gather al the information and translates it into the required grpc struct properties
30-
func BoardDetails(ctx context.Context, req *rpc.BoardDetailsRequest) (*rpc.BoardDetailsResponse, error) {
30+
func (s *arduinoCoreServerImpl) BoardDetails(ctx context.Context, req *rpc.BoardDetailsRequest) (*rpc.BoardDetailsResponse, error) {
3131
pme, release, err := instances.GetPackageManagerExplorer(req.GetInstance())
3232
if err != nil {
3333
return nil, err

Diff for: internal/cli/arguments/programmer.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package arguments
1818
import (
1919
"context"
2020

21-
"github.com/arduino/arduino-cli/commands"
2221
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
2322
"github.com/spf13/cobra"
2423
)
@@ -40,14 +39,14 @@ func (p *Programmer) AddToCommand(cmd *cobra.Command, srv rpc.ArduinoCoreService
4039

4140
// String returns the programmer specified by the user, or the default programmer
4241
// for the given board if defined.
43-
func (p *Programmer) String(inst *rpc.Instance, fqbn string) string {
42+
func (p *Programmer) String(inst *rpc.Instance, srv rpc.ArduinoCoreServiceServer, fqbn string) string {
4443
if p.programmer != "" {
4544
return p.programmer
4645
}
4746
if inst == nil || fqbn == "" {
4847
return ""
4948
}
50-
details, err := commands.BoardDetails(context.Background(), &rpc.BoardDetailsRequest{
49+
details, err := srv.BoardDetails(context.Background(), &rpc.BoardDetailsRequest{
5150
Instance: inst,
5251
Fqbn: fqbn,
5352
})

Diff for: internal/cli/board/details.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"fmt"
2121
"os"
2222

23-
"github.com/arduino/arduino-cli/commands"
2423
"github.com/arduino/arduino-cli/internal/cli/arguments"
2524
"github.com/arduino/arduino-cli/internal/cli/feedback"
2625
"github.com/arduino/arduino-cli/internal/cli/feedback/result"
@@ -44,7 +43,7 @@ func initDetailsCommand(srv rpc.ArduinoCoreServiceServer) *cobra.Command {
4443
Example: " " + os.Args[0] + " board details -b arduino:avr:nano",
4544
Args: cobra.NoArgs,
4645
Run: func(cmd *cobra.Command, args []string) {
47-
runDetailsCommand(fqbn.String(), showFullDetails, listProgrammers, showProperties)
46+
runDetailsCommand(srv, fqbn.String(), showFullDetails, listProgrammers, showProperties)
4847
},
4948
}
5049

@@ -56,7 +55,7 @@ func initDetailsCommand(srv rpc.ArduinoCoreServiceServer) *cobra.Command {
5655
return detailsCommand
5756
}
5857

59-
func runDetailsCommand(fqbn string, showFullDetails, listProgrammers bool, showProperties arguments.ShowProperties) {
58+
func runDetailsCommand(srv rpc.ArduinoCoreServiceServer, fqbn string, showFullDetails, listProgrammers bool, showProperties arguments.ShowProperties) {
6059
inst := instance.CreateAndInit()
6160

6261
logrus.Info("Executing `arduino-cli board details`")
@@ -65,7 +64,7 @@ func runDetailsCommand(fqbn string, showFullDetails, listProgrammers bool, showP
6564
if err != nil {
6665
feedback.Fatal(err.Error(), feedback.ErrBadArgument)
6766
}
68-
res, err := commands.BoardDetails(context.Background(), &rpc.BoardDetailsRequest{
67+
res, err := srv.BoardDetails(context.Background(), &rpc.BoardDetailsRequest{
6968
Instance: inst,
7069
Fqbn: fqbn,
7170
DoNotExpandBuildProperties: showPropertiesMode == arguments.ShowPropertiesUnexpanded,

Diff for: internal/cli/burnbootloader/burnbootloader.go

+6-4
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,10 @@ func NewCommand(srv rpc.ArduinoCoreServiceServer) *cobra.Command {
4848
Short: tr("Upload the bootloader."),
4949
Long: tr("Upload the bootloader on the board using an external programmer."),
5050
Example: " " + os.Args[0] + " burn-bootloader -b arduino:avr:uno -P atmel_ice",
51-
Args: cobra.MaximumNArgs(1),
52-
Run: runBootloaderCommand,
51+
Args: cobra.NoArgs,
52+
Run: func(cmd *cobra.Command, args []string) {
53+
runBootloaderCommand(srv)
54+
},
5355
}
5456

5557
fqbn.AddToCommand(burnBootloaderCommand, srv)
@@ -63,7 +65,7 @@ func NewCommand(srv rpc.ArduinoCoreServiceServer) *cobra.Command {
6365
return burnBootloaderCommand
6466
}
6567

66-
func runBootloaderCommand(command *cobra.Command, args []string) {
68+
func runBootloaderCommand(srv rpc.ArduinoCoreServiceServer) {
6769
instance := instance.CreateAndInit()
6870

6971
logrus.Info("Executing `arduino-cli burn-bootloader`")
@@ -81,7 +83,7 @@ func runBootloaderCommand(command *cobra.Command, args []string) {
8183
Port: discoveryPort,
8284
Verbose: verbose,
8385
Verify: verify,
84-
Programmer: programmer.String(instance, fqbn.String()),
86+
Programmer: programmer.String(instance, srv, fqbn.String()),
8587
DryRun: dryRun,
8688
}, stdOut, stdErr); err != nil {
8789
errcode := feedback.ErrGeneric

Diff for: internal/cli/compile/compile.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ func NewCommand(srv rpc.ArduinoCoreServiceServer) *cobra.Command {
8787
" " + os.Args[0] + ` compile -b arduino:avr:uno --build-property "build.extra_flags=-DPIN=2 \"-DMY_DEFINE=\"hello world\"\"" /home/user/Arduino/MySketch` + "\n" +
8888
" " + os.Args[0] + ` compile -b arduino:avr:uno --build-property build.extra_flags=-DPIN=2 --build-property "compiler.cpp.extra_flags=\"-DSSID=\"hello world\"\"" /home/user/Arduino/MySketch` + "\n",
8989
Args: cobra.MaximumNArgs(1),
90-
Run: runCompileCommand,
90+
Run: func(cmd *cobra.Command, args []string) {
91+
runCompileCommand(cmd, args, srv)
92+
},
9193
}
9294

9395
fqbnArg.AddToCommand(compileCommand, srv)
@@ -140,7 +142,7 @@ func NewCommand(srv rpc.ArduinoCoreServiceServer) *cobra.Command {
140142
return compileCommand
141143
}
142144

143-
func runCompileCommand(cmd *cobra.Command, args []string) {
145+
func runCompileCommand(cmd *cobra.Command, args []string, srv rpc.ArduinoCoreServiceServer) {
144146
logrus.Info("Executing `arduino-cli compile`")
145147

146148
if profileArg.Get() != "" {
@@ -270,7 +272,7 @@ func runCompileCommand(cmd *cobra.Command, args []string) {
270272

271273
prog := profile.GetProgrammer()
272274
if prog == "" || programmer.GetProgrammer() != "" {
273-
prog = programmer.String(inst, fqbn)
275+
prog = programmer.String(inst, srv, fqbn)
274276
}
275277
if prog == "" {
276278
prog = sk.GetDefaultProgrammer()

Diff for: internal/cli/debug/debug.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func NewCommand(srv rpc.ArduinoCoreServiceServer) *cobra.Command {
5656
Example: " " + os.Args[0] + " debug -b arduino:samd:mkr1000 -P atmel_ice /home/user/Arduino/MySketch",
5757
Args: cobra.MaximumNArgs(1),
5858
Run: func(cmd *cobra.Command, args []string) {
59-
runDebugCommand(args, &portArgs, &fqbnArg, interpreter, importDir, &programmer, printInfo, &profileArg)
59+
runDebugCommand(srv, args, &portArgs, &fqbnArg, interpreter, importDir, &programmer, printInfo, &profileArg)
6060
},
6161
}
6262

@@ -72,7 +72,7 @@ func NewCommand(srv rpc.ArduinoCoreServiceServer) *cobra.Command {
7272
return debugCommand
7373
}
7474

75-
func runDebugCommand(args []string, portArgs *arguments.Port, fqbnArg *arguments.Fqbn,
75+
func runDebugCommand(srv rpc.ArduinoCoreServiceServer, args []string, portArgs *arguments.Port, fqbnArg *arguments.Fqbn,
7676
interpreter string, importDir string, programmer *arguments.Programmer, printInfo bool, profileArg *arguments.Profile) {
7777
logrus.Info("Executing `arduino-cli debug`")
7878

@@ -105,7 +105,7 @@ func runDebugCommand(args []string, portArgs *arguments.Port, fqbnArg *arguments
105105

106106
prog := profile.GetProgrammer()
107107
if prog == "" || programmer.GetProgrammer() != "" {
108-
prog = programmer.String(inst, fqbn)
108+
prog = programmer.String(inst, srv, fqbn)
109109
}
110110
if prog == "" {
111111
prog = sk.GetDefaultProgrammer()

Diff for: internal/cli/debug/debug_check.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func newDebugCheckCommand(srv rpc.ArduinoCoreServiceServer) *cobra.Command {
4141
Short: tr("Check if the given board/programmer combination supports debugging."),
4242
Example: " " + os.Args[0] + " debug check -b arduino:samd:mkr1000 -P atmel_ice",
4343
Run: func(cmd *cobra.Command, args []string) {
44-
runDebugCheckCommand(&portArgs, &fqbnArg, interpreter, &programmer)
44+
runDebugCheckCommand(srv, &portArgs, &fqbnArg, interpreter, &programmer)
4545
},
4646
}
4747
fqbnArg.AddToCommand(debugCheckCommand, srv)
@@ -51,7 +51,7 @@ func newDebugCheckCommand(srv rpc.ArduinoCoreServiceServer) *cobra.Command {
5151
return debugCheckCommand
5252
}
5353

54-
func runDebugCheckCommand(portArgs *arguments.Port, fqbnArg *arguments.Fqbn, interpreter string, programmerArg *arguments.Programmer) {
54+
func runDebugCheckCommand(srv rpc.ArduinoCoreServiceServer, portArgs *arguments.Port, fqbnArg *arguments.Fqbn, interpreter string, programmerArg *arguments.Programmer) {
5555
instance := instance.CreateAndInit()
5656
logrus.Info("Executing `arduino-cli debug`")
5757

@@ -65,7 +65,7 @@ func runDebugCheckCommand(portArgs *arguments.Port, fqbnArg *arguments.Fqbn, int
6565
Fqbn: fqbn,
6666
Port: port,
6767
Interpreter: interpreter,
68-
Programmer: programmerArg.String(instance, fqbn),
68+
Programmer: programmerArg.String(instance, srv, fqbn),
6969
})
7070
if err != nil {
7171
feedback.FatalError(err, feedback.ErrGeneric)

Diff for: internal/cli/upload/upload.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func NewCommand(srv rpc.ArduinoCoreServiceServer) *cobra.Command {
6363
arguments.CheckFlagsConflicts(cmd, "input-file", "input-dir")
6464
},
6565
Run: func(cmd *cobra.Command, args []string) {
66-
runUploadCommand(args, uploadFields)
66+
runUploadCommand(srv, args, uploadFields)
6767
},
6868
}
6969

@@ -81,7 +81,7 @@ func NewCommand(srv rpc.ArduinoCoreServiceServer) *cobra.Command {
8181
return uploadCommand
8282
}
8383

84-
func runUploadCommand(args []string, uploadFieldsArgs map[string]string) {
84+
func runUploadCommand(srv rpc.ArduinoCoreServiceServer, args []string, uploadFieldsArgs map[string]string) {
8585
logrus.Info("Executing `arduino-cli upload`")
8686

8787
path := ""
@@ -176,7 +176,7 @@ func runUploadCommand(args []string, uploadFieldsArgs map[string]string) {
176176

177177
prog := profile.GetProgrammer()
178178
if prog == "" || programmer.GetProgrammer() != "" {
179-
prog = programmer.String(inst, fqbn)
179+
prog = programmer.String(inst, srv, fqbn)
180180
}
181181
if prog == "" {
182182
prog = sketch.GetDefaultProgrammer()

0 commit comments

Comments
 (0)