@@ -305,15 +305,16 @@ func runCompileCommand(cmd *cobra.Command, args []string) {
305
305
}
306
306
307
307
stdIO := stdIORes ()
308
- feedback . PrintResult ( & compileResult {
308
+ res := & compileResult {
309
309
CompilerOut : stdIO .Stdout ,
310
310
CompilerErr : stdIO .Stderr ,
311
311
BuilderResult : compileRes ,
312
312
ProfileOut : profileOut ,
313
313
Success : compileError == nil ,
314
- })
314
+ }
315
+
315
316
if compileError != nil {
316
- msg : = tr ("Error during build: %v" , compileError )
317
+ res . Error = tr ("Error during build: %v" , compileError )
317
318
318
319
// Check the error type to give the user better feedback on how
319
320
// to resolve it
@@ -333,17 +334,18 @@ func runCompileCommand(cmd *cobra.Command, args []string) {
333
334
release ()
334
335
335
336
if profileArg .String () == "" {
336
- msg += " \n "
337
+ res . Error += fmt . Sprintln ()
337
338
if platform != nil {
338
339
suggestion := fmt .Sprintf ("`%s core install %s`" , version .VersionInfo .Application , platformErr .Platform )
339
- msg += tr ("Try running %s" , suggestion )
340
+ res . Error += tr ("Try running %s" , suggestion )
340
341
} else {
341
- msg += tr ("Platform %s is not found in any known index\n Maybe you need to add a 3rd party URL?" , platformErr .Platform )
342
+ res . Error += tr ("Platform %s is not found in any known index\n Maybe you need to add a 3rd party URL?" , platformErr .Platform )
342
343
}
343
344
}
344
345
}
345
- feedback .Fatal ( msg , feedback .ErrGeneric )
346
+ feedback .FatalResult ( res , feedback .ErrGeneric )
346
347
}
348
+ feedback .PrintResult (res )
347
349
}
348
350
349
351
type compileResult struct {
@@ -352,6 +354,7 @@ type compileResult struct {
352
354
BuilderResult * rpc.CompileResponse `json:"builder_result"`
353
355
Success bool `json:"success"`
354
356
ProfileOut string `json:"profile_out,omitempty"`
357
+ Error string `json:"error,omitempty"`
355
358
}
356
359
357
360
func (r * compileResult ) Data () interface {} {
@@ -365,8 +368,8 @@ func (r *compileResult) String() string {
365
368
build := r .BuilderResult
366
369
367
370
res := "\n "
368
- libraries := table .New ()
369
371
if len (build .GetUsedLibraries ()) > 0 {
372
+ libraries := table .New ()
370
373
libraries .SetHeader (
371
374
table .NewCell (tr ("Used library" ), titleColor ),
372
375
table .NewCell (tr ("Version" ), titleColor ),
@@ -377,8 +380,8 @@ func (r *compileResult) String() string {
377
380
l .GetVersion (),
378
381
table .NewCell (l .GetInstallDir (), pathColor ))
379
382
}
383
+ res += fmt .Sprintln (libraries .Render ())
380
384
}
381
- res += libraries .Render () + "\n "
382
385
383
386
if boardPlatform := build .GetBoardPlatform (); boardPlatform != nil {
384
387
platforms := table .New ()
@@ -398,10 +401,10 @@ func (r *compileResult) String() string {
398
401
buildPlatform .GetVersion (),
399
402
table .NewCell (buildPlatform .GetInstallDir (), pathColor ))
400
403
}
401
- res += platforms .Render ()
404
+ res += fmt . Sprintln ( platforms .Render () )
402
405
}
403
406
if r .ProfileOut != "" {
404
- res += " \n " + fmt .Sprintln (r .ProfileOut )
407
+ res += fmt .Sprintln (r .ProfileOut )
405
408
}
406
- return res
409
+ return strings . TrimRight ( res , fmt . Sprintln ())
407
410
}
0 commit comments