@@ -33,6 +33,7 @@ import (
33
33
"github.com/arduino/arduino-cli/i18n"
34
34
"github.com/arduino/arduino-cli/internal/cli/arguments"
35
35
"github.com/arduino/arduino-cli/internal/cli/feedback"
36
+ "github.com/arduino/arduino-cli/internal/cli/feedback/result"
36
37
"github.com/arduino/arduino-cli/internal/cli/instance"
37
38
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
38
39
"github.com/arduino/arduino-cli/table"
@@ -340,10 +341,14 @@ func runCompileCommand(cmd *cobra.Command, args []string) {
340
341
341
342
stdIO := stdIORes ()
342
343
res := & compileResult {
343
- CompilerOut : stdIO .Stdout ,
344
- CompilerErr : stdIO .Stderr ,
345
- BuilderResult : compileRes ,
346
- UploadResult : uploadRes ,
344
+ CompilerOut : stdIO .Stdout ,
345
+ CompilerErr : stdIO .Stderr ,
346
+ BuilderResult : result .NewCompileResponse (compileRes ),
347
+ UploadResult : struct {
348
+ UpdatedUploadPort * result.Port `json:"updated_upload_port,omitempty"`
349
+ }{
350
+ UpdatedUploadPort : result .NewPort (uploadRes .GetUpdatedUploadPort ()),
351
+ },
347
352
ProfileOut : profileOut ,
348
353
Success : compileError == nil ,
349
354
showPropertiesMode : showProperties ,
@@ -385,13 +390,15 @@ func runCompileCommand(cmd *cobra.Command, args []string) {
385
390
}
386
391
387
392
type compileResult struct {
388
- CompilerOut string `json:"compiler_out"`
389
- CompilerErr string `json:"compiler_err"`
390
- BuilderResult * rpc.CompileResponse `json:"builder_result"`
391
- UploadResult * rpc.UploadResult `json:"upload_result"`
392
- Success bool `json:"success"`
393
- ProfileOut string `json:"profile_out,omitempty"`
394
- Error string `json:"error,omitempty"`
393
+ CompilerOut string `json:"compiler_out"`
394
+ CompilerErr string `json:"compiler_err"`
395
+ BuilderResult * result.CompileResponse `json:"builder_result"`
396
+ UploadResult struct {
397
+ UpdatedUploadPort * result.Port `json:"updated_upload_port,omitempty"`
398
+ } `json:"upload_result"`
399
+ Success bool `json:"success"`
400
+ ProfileOut string `json:"profile_out,omitempty"`
401
+ Error string `json:"error,omitempty"`
395
402
396
403
showPropertiesMode arguments.ShowPropertiesMode
397
404
hideStats bool
@@ -402,8 +409,8 @@ func (r *compileResult) Data() interface{} {
402
409
}
403
410
404
411
func (r * compileResult ) String () string {
405
- if r .showPropertiesMode != arguments .ShowPropertiesDisabled {
406
- return strings .Join (r .BuilderResult .GetBuildProperties () , fmt .Sprintln ())
412
+ if r .BuilderResult != nil && r . showPropertiesMode != arguments .ShowPropertiesDisabled {
413
+ return strings .Join (r .BuilderResult .BuildProperties , fmt .Sprintln ())
407
414
}
408
415
409
416
if r .hideStats {
@@ -419,38 +426,41 @@ func (r *compileResult) String() string {
419
426
if r .CompilerOut != "" || r .CompilerErr != "" {
420
427
res += fmt .Sprintln ()
421
428
}
422
- if len (build .GetUsedLibraries () ) > 0 {
429
+ if build != nil && len (build .UsedLibraries ) > 0 {
423
430
libraries := table .New ()
424
431
libraries .SetHeader (
425
432
table .NewCell (tr ("Used library" ), titleColor ),
426
433
table .NewCell (tr ("Version" ), titleColor ),
427
434
table .NewCell (tr ("Path" ), pathColor ))
428
- for _ , l := range build .GetUsedLibraries () {
435
+ for _ , l := range build .UsedLibraries {
436
+ if l == nil {
437
+ continue
438
+ }
429
439
libraries .AddRow (
430
- table .NewCell (l .GetName () , nameColor ),
431
- l .GetVersion () ,
432
- table .NewCell (l .GetInstallDir () , pathColor ))
440
+ table .NewCell (l .Name , nameColor ),
441
+ l .Version ,
442
+ table .NewCell (l .InstallDir , pathColor ))
433
443
}
434
444
res += fmt .Sprintln (libraries .Render ())
435
445
}
436
-
437
- if boardPlatform := build .GetBoardPlatform (); boardPlatform != nil {
446
+ if build != nil && build . BoardPlatform != nil {
447
+ boardPlatform := build .BoardPlatform
438
448
platforms := table .New ()
439
449
platforms .SetHeader (
440
450
table .NewCell (tr ("Used platform" ), titleColor ),
441
451
table .NewCell (tr ("Version" ), titleColor ),
442
452
table .NewCell (tr ("Path" ), pathColor ))
443
453
platforms .AddRow (
444
- table .NewCell (boardPlatform .GetId () , nameColor ),
445
- boardPlatform .GetVersion () ,
446
- table .NewCell (boardPlatform .GetInstallDir () , pathColor ))
447
- if buildPlatform := build .GetBuildPlatform () ; buildPlatform != nil &&
454
+ table .NewCell (boardPlatform .Id , nameColor ),
455
+ boardPlatform .Version ,
456
+ table .NewCell (boardPlatform .InstallDir , pathColor ))
457
+ if buildPlatform := build .BuildPlatform ; buildPlatform != nil &&
448
458
buildPlatform .Id != boardPlatform .Id &&
449
459
buildPlatform .Version != boardPlatform .Version {
450
460
platforms .AddRow (
451
- table .NewCell (buildPlatform .GetId () , nameColor ),
452
- buildPlatform .GetVersion () ,
453
- table .NewCell (buildPlatform .GetInstallDir () , pathColor ))
461
+ table .NewCell (buildPlatform .Id , nameColor ),
462
+ buildPlatform .Version ,
463
+ table .NewCell (buildPlatform .InstallDir , pathColor ))
454
464
}
455
465
res += fmt .Sprintln (platforms .Render ())
456
466
}
0 commit comments