@@ -305,15 +305,16 @@ func runCompileCommand(cmd *cobra.Command, args []string) {
305305 }
306306
307307 stdIO := stdIORes ()
308- feedback . PrintResult ( & compileResult {
308+ res := & compileResult {
309309 CompilerOut : stdIO .Stdout ,
310310 CompilerErr : stdIO .Stderr ,
311311 BuilderResult : compileRes ,
312312 ProfileOut : profileOut ,
313313 Success : compileError == nil ,
314- })
314+ }
315+
315316 if compileError != nil {
316- msg : = tr ("Error during build: %v" , compileError )
317+ res . Error = tr ("Error during build: %v" , compileError )
317318
318319 // Check the error type to give the user better feedback on how
319320 // to resolve it
@@ -333,17 +334,17 @@ func runCompileCommand(cmd *cobra.Command, args []string) {
333334 release ()
334335
335336 if profileArg .String () == "" {
336- msg += "\n "
337337 if platform != nil {
338338 suggestion := fmt .Sprintf ("`%s core install %s`" , version .VersionInfo .Application , platformErr .Platform )
339- msg + = tr ("Try running %s" , suggestion )
339+ res . Suggestion = tr ("Try running %s" , suggestion )
340340 } 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 )
341+ res . Suggestion = tr ("Platform %s is not found in any known index\n Maybe you need to add a 3rd party URL?" , platformErr .Platform )
342342 }
343343 }
344344 }
345- feedback .Fatal ( msg , feedback .ErrGeneric )
345+ feedback .FatalResult ( res , feedback .ErrGeneric )
346346 }
347+ feedback .PrintResult (res )
347348}
348349
349350type compileResult struct {
@@ -352,6 +353,8 @@ type compileResult struct {
352353 BuilderResult * rpc.CompileResponse `json:"builder_result"`
353354 Success bool `json:"success"`
354355 ProfileOut string `json:"profile_out,omitempty"`
356+ Error string `json:"error,omitempty"`
357+ Suggestion string `json:"suggestion,omitempty"`
355358}
356359
357360func (r * compileResult ) Data () interface {} {
@@ -365,8 +368,8 @@ func (r *compileResult) String() string {
365368 build := r .BuilderResult
366369
367370 res := "\n "
368- libraries := table .New ()
369371 if len (build .GetUsedLibraries ()) > 0 {
372+ libraries := table .New ()
370373 libraries .SetHeader (
371374 table .NewCell (tr ("Used library" ), titleColor ),
372375 table .NewCell (tr ("Version" ), titleColor ),
@@ -377,8 +380,8 @@ func (r *compileResult) String() string {
377380 l .GetVersion (),
378381 table .NewCell (l .GetInstallDir (), pathColor ))
379382 }
383+ res += fmt .Sprintln (libraries .Render ())
380384 }
381- res += libraries .Render () + "\n "
382385
383386 if boardPlatform := build .GetBoardPlatform (); boardPlatform != nil {
384387 platforms := table .New ()
@@ -398,10 +401,16 @@ func (r *compileResult) String() string {
398401 buildPlatform .GetVersion (),
399402 table .NewCell (buildPlatform .GetInstallDir (), pathColor ))
400403 }
401- res += platforms .Render ()
404+ res += fmt .Sprintln (platforms .Render ())
405+ }
406+ if r .Error != "" {
407+ res += fmt .Sprintln (r .Error )
402408 }
403409 if r .ProfileOut != "" {
404- res += "\n " + fmt .Sprintln (r .ProfileOut )
410+ res += fmt .Sprintln (r .ProfileOut )
411+ }
412+ if r .Suggestion != "" {
413+ res += fmt .Sprintln (r .Suggestion )
405414 }
406- return res
415+ return strings . TrimRight ( res , fmt . Sprintln ())
407416}
0 commit comments