Skip to content

[breaking] Clean up and refactor --format json and, in general, how Arduino CLI output is handled #2003

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 45 commits into from
Jan 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
ecec676
Added source code static-check to enforce `--format` output.
cmaglie Dec 1, 2022
3604efa
Slightly improved naming/docs of OutputFormat enumeration
cmaglie Dec 1, 2022
922a3eb
Removed `feedback.Feedback` since only the global instance is used
cmaglie Dec 1, 2022
4d593ad
Moved `cli/output` package into `cli/feedback`
cmaglie Dec 1, 2022
93c2d62
Print progress bar and task progess only on interactive terminals
cmaglie Dec 1, 2022
766da7f
Use feedback functions to output task progress
cmaglie Dec 1, 2022
344669e
User-input functions are now moved into `feedback` package
cmaglie Dec 4, 2022
c850c16
Fix user-input function
cmaglie Dec 4, 2022
53c80b0
Added cmd to test feedback functions
cmaglie Dec 4, 2022
94cb4b5
Better error message
cmaglie Dec 4, 2022
5c41e74
Removed unprotected print
cmaglie Dec 4, 2022
07f4bd0
Removed useless response from Upload and UploadWithProgrammer
cmaglie Dec 5, 2022
36817e7
VersionInfo now implements feedback.Result interface
cmaglie Dec 5, 2022
8d6b33d
Added `feedback` support for direct streaming
cmaglie Dec 6, 2022
5d1fef1
Replace direct use of os.Stdout/Stderr in Upload command
cmaglie Dec 6, 2022
017258c
Implemented feedback.Fatal and FatalError
cmaglie Dec 6, 2022
ad48671
Added output buffers in error messages (if used)
cmaglie Dec 6, 2022
0563574
Removed direct access to stdio streams in monitor command
cmaglie Dec 6, 2022
206370a
Removed direct access to stdio streams in debug command
cmaglie Dec 6, 2022
43d3889
Removed direct access to stdio streams in daemon command
cmaglie Dec 6, 2022
a8c0121
Removed direct access to stdio streams in burn-bootlodaer command
cmaglie Dec 6, 2022
94faeab
Removed direct access to stdio streams in compile command
cmaglie Dec 6, 2022
c2fb4b0
Removed direct access to stdio streams in completion command
cmaglie Dec 6, 2022
9ae0d39
compile: print platforms stats only if present
cmaglie Dec 6, 2022
f64b08b
Removed direct access to stdio streams in --dump-profile command
cmaglie Dec 7, 2022
bbc2a50
Added feedback functions to report warnings
cmaglie Dec 7, 2022
2d0d667
Moved `errorcodes` into `feedback`
cmaglie Dec 9, 2022
61fb1c8
Remove direct os.Stdin access from daemon command
cmaglie Dec 9, 2022
bb0c707
Removed redundant `cli/globals` package
cmaglie Dec 12, 2022
744093a
Made `cli` package internal
cmaglie Dec 12, 2022
6310e1e
updated docs
cmaglie Dec 12, 2022
8e70a61
Removed redundant logic in getter for stdio streams
cmaglie Jan 3, 2023
68be5fa
Internationalize more strings
cmaglie Jan 3, 2023
08fb7e6
Spellcheck internal/cli/feedback/stdio.go
cmaglie Jan 3, 2023
8586cde
Spellcheck internal/cli/feedback/feedback_cmd.go
cmaglie Jan 3, 2023
6a4a1dc
feedback: remove stray '\r' on Windows on interactive input
cmaglie Jan 4, 2023
722138d
Ban use of os.Exit from cli package
cmaglie Jan 4, 2023
ca2451b
Removed unused parameter in compile.Compile
cmaglie Jan 4, 2023
d2db935
Non-interactive stream are always buffered
cmaglie Jan 12, 2023
3ef55a6
Use direct streams where appropiate
cmaglie Jan 12, 2023
3b20b8d
Compile outputs profile dump as part of the result
cmaglie Jan 12, 2023
ab8a756
Report saved warnings also when erroring out
cmaglie Jan 12, 2023
4e05142
Print compile error and suggestions as part of the result
cmaglie Jan 12, 2023
5735f8a
Add trailing newline only if compiler has produced output
cmaglie Jan 12, 2023
3d5ea52
FatalResult now outputs the error on stderr
cmaglie Jan 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions arduino/discovery/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ import (
"sync"
"time"

"github.com/arduino/arduino-cli/cli/globals"
"github.com/arduino/arduino-cli/executils"
"github.com/arduino/arduino-cli/i18n"
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
"github.com/arduino/arduino-cli/version"
"github.com/arduino/go-properties-orderedmap"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -301,7 +301,7 @@ func (disc *PluggableDiscovery) Run() (err error) {
}
}()

if err = disc.sendCommand("HELLO 1 \"arduino-cli " + globals.VersionInfo.VersionString + "\"\n"); err != nil {
if err = disc.sendCommand("HELLO 1 \"arduino-cli " + version.VersionInfo.VersionString + "\"\n"); err != nil {
return err
}
if msg, err := disc.waitMessage(time.Second * 10); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions arduino/monitor/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import (
"strings"
"time"

"github.com/arduino/arduino-cli/cli/globals"
"github.com/arduino/arduino-cli/executils"
"github.com/arduino/arduino-cli/i18n"
"github.com/arduino/arduino-cli/version"
"github.com/sirupsen/logrus"
)

Expand Down Expand Up @@ -227,7 +227,7 @@ func (mon *PluggableMonitor) Run() (err error) {
}
}()

if err = mon.sendCommand("HELLO 1 \"arduino-cli " + globals.VersionInfo.VersionString + "\"\n"); err != nil {
if err = mon.sendCommand("HELLO 1 \"arduino-cli " + version.VersionInfo.VersionString + "\"\n"); err != nil {
return err
}
if msg, err := mon.waitMessage(time.Second*10, "hello"); err != nil {
Expand Down
91 changes: 0 additions & 91 deletions cli/feedback/exported.go

This file was deleted.

189 changes: 0 additions & 189 deletions cli/feedback/feedback.go

This file was deleted.

28 changes: 0 additions & 28 deletions cli/globals/globals.go

This file was deleted.

2 changes: 1 addition & 1 deletion commands/compile/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import (
var tr = i18n.Tr

// Compile FIXMEDOC
func Compile(ctx context.Context, req *rpc.CompileRequest, outStream, errStream io.Writer, progressCB rpc.TaskProgressCB, debug bool) (r *rpc.CompileResponse, e error) {
func Compile(ctx context.Context, req *rpc.CompileRequest, outStream, errStream io.Writer, progressCB rpc.TaskProgressCB) (r *rpc.CompileResponse, e error) {

// There is a binding between the export binaries setting and the CLI flag to explicitly set it,
// since we want this binding to work also for the gRPC interface we must read it here in this
Expand Down
2 changes: 1 addition & 1 deletion commands/core/search_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import (
"os"
"testing"

"github.com/arduino/arduino-cli/cli/instance"
"github.com/arduino/arduino-cli/configuration"
"github.com/arduino/arduino-cli/internal/cli/instance"
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
"github.com/arduino/go-paths-helper"
"github.com/stretchr/testify/require"
Expand Down
Loading