Skip to content

Commit

Permalink
Updated all --format json references to use --json
Browse files Browse the repository at this point in the history
  • Loading branch information
cmaglie committed Apr 29, 2024
1 parent c0dfacc commit e883b64
Show file tree
Hide file tree
Showing 19 changed files with 244 additions and 244 deletions.
37 changes: 19 additions & 18 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,35 @@ IDE. Let's see some examples.

```console
$ arduino-cli help core
Arduino Core operations.
Arduino core operations.

Usage:
arduino-cli core [command]
arduino-cli core [command]

Examples:
./arduino-cli core update-index
arduino-cli core update-index

Available Commands:
download Downloads one or more cores and corresponding tool dependencies.
install Installs one or more cores and corresponding tool dependencies.
list Shows the list of installed platforms.
search Search for a core in Boards Manager.
uninstall Uninstalls one or more cores and corresponding tool dependencies if no more used.
update-index Updates the index of cores.
upgrade Upgrades one or all installed platforms to the latest version.
download Downloads one or more cores and corresponding tool dependencies.
install Installs one or more cores and corresponding tool dependencies.
list Shows the list of installed platforms.
search Search for a core in Boards Manager.
uninstall Uninstalls one or more cores and corresponding tool dependencies if no longer used.
update-index Updates the index of cores.
upgrade Upgrades one or all installed platforms to the latest version.

Flags:
-h, --help help for core
-h, --help help for core

Global Flags:
--additional-urls strings Additional URLs for Boards Manager.
--config-file string The custom config file (if not specified the default will be used).
--format string The output format, can be [text|json]. (default "text")
--log-file string Path to the file where logs will be written.
--log-format string The output format for the logs, can be [text|json].
--log-level string Messages with this level and above will be logged.
-v, --verbose Print the logs on the standard output.
--additional-urls strings Comma-separated list of additional URLs for the Boards Manager.
--config-file string The custom config file (if not specified the default will be used).
--json Print the output in JSON format.
--log Print the logs on the standard output.
--log-file string Path to the file where logs will be written.
--log-format string The output format for the logs, can be: text, json
--log-level string Messages with this level and above will be logged. Valid levels are: trace, debug, info, warn, error, fatal, panic
--no-color Disable colored output.

Use "arduino-cli core [command] --help" for more information about a command.
```
Expand Down
4 changes: 2 additions & 2 deletions docs/versioning.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ The following changes to the command-line syntax are NOT considered breaking:
Any change in the **human-readable** text output is **NOT** considered a breaking change. In general, the human-readable
text is subject to translation and small adjustments in natural language syntax and presentation.

We will consider breaking changes only in the **machine-readable** output of the commands using the `--format json`
flag. In particular, we have a breaking change in the JSON command output if:
We will consider breaking changes only in the **machine-readable** output of the commands using the `--json` flag. In
particular, we have a breaking change in the JSON command output if:

- a key in a JSON object is renamed or removed.
- a value in a JSON object or array changes meaning or changes format.
Expand Down
2 changes: 1 addition & 1 deletion internal/cli/core/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func Upgrade(inst *rpc.Instance, args []string, skipPostInstall bool, skipPreUni
feedback.PrintResult(&platformUpgradeResult{})
}

// This is needed so we can print warning messages in case users use --format json
// This is needed so we can print warning messages in case users use --json
type platformUpgradeResult struct{}

// Data implements feedback.Result.
Expand Down
2 changes: 1 addition & 1 deletion internal/integrationtest/arduino-cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ func (cli *ArduinoCLI) run(stdoutBuff, stderrBuff io.Writer, stdinBuff io.Reader

// StartDaemon starts the Arduino CLI daemon. It returns the address of the daemon.
func (cli *ArduinoCLI) StartDaemon(verbose bool) string {
args := []string{"daemon", "--format", "json"}
args := []string{"daemon", "--json"}
if cli.cliConfigPath != nil {
args = append([]string{"--config-file", cli.cliConfigPath.String()}, args...)
}
Expand Down
40 changes: 20 additions & 20 deletions internal/integrationtest/board/board_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestCorrectBoardListOrdering(t *testing.T) {
require.NoError(t, err)
_, _, err = cli.Run("core", "install", "arduino:avr")
require.NoError(t, err)
jsonOut, _, err := cli.Run("board", "listall", "--format", "json")
jsonOut, _, err := cli.Run("board", "listall", "--json")
require.NoError(t, err)
requirejson.Query(t, jsonOut, "[.boards[] | .fqbn]", `[
"arduino:avr:yun",
Expand Down Expand Up @@ -80,7 +80,7 @@ func TestBoardList(t *testing.T) {

cli.InstallMockedSerialDiscovery(t)

stdout, _, err := cli.Run("board", "list", "--format", "json")
stdout, _, err := cli.Run("board", "list", "--json")
require.NoError(t, err)
// check is a valid json and contains a list of ports
requirejson.Parse(t, stdout).
Expand All @@ -97,7 +97,7 @@ func TestBoardListMock(t *testing.T) {

cli.InstallMockedSerialDiscovery(t)

stdout, _, err := cli.Run("board", "list", "--format", "json")
stdout, _, err := cli.Run("board", "list", "--json")
require.NoError(t, err)

// check is a valid json and contains a list of ports
Expand Down Expand Up @@ -136,7 +136,7 @@ func TestBoardListWithFqbnFilter(t *testing.T) {

cli.InstallMockedSerialDiscovery(t)

stdout, _, err := cli.Run("board", "list", "-b", "foo:bar:baz", "--format", "json")
stdout, _, err := cli.Run("board", "list", "-b", "foo:bar:baz", "--json")
require.NoError(t, err)
requirejson.Query(t, stdout, `.detected_ports | length`, `0`)
}
Expand All @@ -150,7 +150,7 @@ func TestBoardListWithFqbnFilterInvalid(t *testing.T) {

cli.InstallMockedSerialDiscovery(t)

_, stderr, err := cli.Run("board", "list", "-b", "yadayada", "--format", "json")
_, stderr, err := cli.Run("board", "list", "-b", "yadayada", "--json")
require.Error(t, err)
requirejson.Query(t, stderr, ".error", `"Invalid FQBN: not an FQBN: yadayada"`)
}
Expand All @@ -164,7 +164,7 @@ func TestBoardListall(t *testing.T) {
_, _, err = cli.Run("core", "install", "arduino:[email protected]")
require.NoError(t, err)

stdout, _, err := cli.Run("board", "listall", "--format", "json")
stdout, _, err := cli.Run("board", "listall", "--json")
require.NoError(t, err)

requirejson.Query(t, stdout, ".boards | length", "26")
Expand Down Expand Up @@ -224,7 +224,7 @@ func TestBoardListallWithManuallyInstalledPlatform(t *testing.T) {
})
require.NoError(t, err)

stdout, _, err := cli.Run("board", "listall", "--format", "json")
stdout, _, err := cli.Run("board", "listall", "--json")
require.NoError(t, err)

requirejson.Query(t, stdout, ".boards | length", "17")
Expand Down Expand Up @@ -274,11 +274,11 @@ func TestBoardDetails(t *testing.T) {
require.NoError(t, err)

// Test board listall with and without showing hidden elements
stdout, _, err := cli.Run("board", "listall", "MIPS", "--format", "json")
stdout, _, err := cli.Run("board", "listall", "MIPS", "--json")
require.NoError(t, err)
require.Equal(t, string(stdout), "{}\n")

stdout, _, err = cli.Run("board", "listall", "MIPS", "-a", "--format", "json")
stdout, _, err = cli.Run("board", "listall", "MIPS", "-a", "--json")
require.NoError(t, err)
requirejson.Contains(t, stdout, `{
"boards": [
Expand All @@ -288,7 +288,7 @@ func TestBoardDetails(t *testing.T) {
]
}`)

stdout, _, err = cli.Run("board", "details", "-b", "arduino:samd:nano_33_iot", "--format", "json")
stdout, _, err = cli.Run("board", "details", "-b", "arduino:samd:nano_33_iot", "--json")
require.NoError(t, err)

requirejson.Contains(t, stdout, `{
Expand Down Expand Up @@ -425,7 +425,7 @@ func TestBoardSearch(t *testing.T) {
_, _, err := cli.Run("update")
require.NoError(t, err)

stdout, _, err := cli.Run("board", "search", "--format", "json")
stdout, _, err := cli.Run("board", "search", "--json")
require.NoError(t, err)
// Verifies boards are returned
requirejson.NotEmpty(t, stdout)
Expand All @@ -441,7 +441,7 @@ func TestBoardSearch(t *testing.T) {
]}`)

// Search in non installed boards
stdout, _, err = cli.Run("board", "search", "--format", "json", "nano", "33")
stdout, _, err = cli.Run("board", "search", "--json", "nano", "33")
require.NoError(t, err)
// Verifies boards are returned
requirejson.NotEmpty(t, stdout)
Expand All @@ -457,7 +457,7 @@ func TestBoardSearch(t *testing.T) {
_, _, err = cli.Run("core", "install", "arduino:[email protected]")
require.NoError(t, err)

stdout, _, err = cli.Run("board", "search", "--format", "json")
stdout, _, err = cli.Run("board", "search", "--json")
require.NoError(t, err)
requirejson.NotEmpty(t, stdout)
// Verifies some FQBNs are now returned after installing a platform
Expand All @@ -474,7 +474,7 @@ func TestBoardSearch(t *testing.T) {
}
]}`)

stdout, _, err = cli.Run("board", "search", "--format", "json", "arduino", "yun")
stdout, _, err = cli.Run("board", "search", "--json", "arduino", "yun")
require.NoError(t, err)
requirejson.NotEmpty(t, stdout)
requirejson.Contains(t, stdout, `{
Expand All @@ -494,7 +494,7 @@ func TestBoardSearch(t *testing.T) {
})
require.NoError(t, err)

stdout, _, err = cli.Run("board", "search", "--format", "json")
stdout, _, err = cli.Run("board", "search", "--json")
require.NoError(t, err)
requirejson.NotEmpty(t, stdout)
// Verifies some FQBNs are now returned after installing a platform
Expand Down Expand Up @@ -531,7 +531,7 @@ func TestBoardSearch(t *testing.T) {
}
]}`)

stdout, _, err = cli.Run("board", "search", "--format", "json", "mkr1000")
stdout, _, err = cli.Run("board", "search", "--json", "mkr1000")
require.NoError(t, err)
requirejson.NotEmpty(t, stdout)
// Verifies some FQBNs are now returned after installing a platform
Expand All @@ -557,7 +557,7 @@ func TestBoardAttach(t *testing.T) {
require.NoError(t, err)

{
stdout, _, err := cli.Run("board", "attach", "-b", "arduino:avr:uno", sketchPath.String(), "--format", "json")
stdout, _, err := cli.Run("board", "attach", "-b", "arduino:avr:uno", sketchPath.String(), "--json")
require.NoError(t, err)
requirejson.Query(t, stdout, ".fqbn", `"arduino:avr:uno"`)

Expand All @@ -568,7 +568,7 @@ func TestBoardAttach(t *testing.T) {
require.NotContains(t, string(yamlData), "default_protocol:")
}
{
stdout, _, err := cli.Run("board", "attach", "-p", "/dev/ttyACM0", "-l", "serial", sketchPath.String(), "--format", "json")
stdout, _, err := cli.Run("board", "attach", "-p", "/dev/ttyACM0", "-l", "serial", sketchPath.String(), "--json")
require.NoError(t, err)
requirejson.Query(t, stdout, ".fqbn", `"arduino:avr:uno"`)
requirejson.Query(t, stdout, ".port.address", `"/dev/ttyACM0"`)
Expand All @@ -581,7 +581,7 @@ func TestBoardAttach(t *testing.T) {
require.Contains(t, string(yamlData), "default_protocol: serial")
}
{
stdout, _, err := cli.Run("board", "attach", "-p", "/dev/ttyACM0", sketchPath.String(), "--format", "json")
stdout, _, err := cli.Run("board", "attach", "-p", "/dev/ttyACM0", sketchPath.String(), "--json")
require.NoError(t, err)
requirejson.Query(t, stdout, ".fqbn", `"arduino:avr:uno"`)
requirejson.Query(t, stdout, ".port.address", `"/dev/ttyACM0"`)
Expand All @@ -594,7 +594,7 @@ func TestBoardAttach(t *testing.T) {
require.NotContains(t, string(yamlData), "default_protocol:")
}
{
stdout, _, err := cli.Run("board", "attach", "-b", "arduino:samd:mkr1000", "-P", "atmel_ice", sketchPath.String(), "--format", "json")
stdout, _, err := cli.Run("board", "attach", "-b", "arduino:samd:mkr1000", "-P", "atmel_ice", sketchPath.String(), "--json")
require.NoError(t, err)
requirejson.Query(t, stdout, ".fqbn", `"arduino:samd:mkr1000"`)
requirejson.Query(t, stdout, ".programmer", `"atmel_ice"`)
Expand Down
16 changes: 8 additions & 8 deletions internal/integrationtest/board/hardware_loading_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestHardwareLoading(t *testing.T) {

t.Run("Simple", func(t *testing.T) {
{
out, _, err := cli.Run("core", "list", "--format", "json")
out, _, err := cli.Run("core", "list", "--json")
require.NoError(t, err)
jsonOut := requirejson.Parse(t, out)
jsonOut.LengthMustEqualTo(1)
Expand Down Expand Up @@ -73,7 +73,7 @@ func TestHardwareLoading(t *testing.T) {

{
// Also test local platform.txt properties override
out, _, err := cli.Run("board", "details", "-b", "arduino:avr:uno", "--format", "json")
out, _, err := cli.Run("board", "details", "-b", "arduino:avr:uno", "--json")
require.NoError(t, err)
jsonOut := requirejson.Parse(t, out)
jsonOut.MustContain(`{
Expand All @@ -100,7 +100,7 @@ func TestHardwareLoading(t *testing.T) {
}

{
out, _, err := cli.Run("board", "details", "-b", "arduino:avr:yun", "--format", "json")
out, _, err := cli.Run("board", "details", "-b", "arduino:avr:yun", "--json")
require.NoError(t, err)
jsonOut := requirejson.Parse(t, out)
jsonOut.MustContain(`{
Expand All @@ -115,7 +115,7 @@ func TestHardwareLoading(t *testing.T) {

{
// Check un-expansion of board_properties
out, _, err := cli.Run("board", "details", "-b", "arduino:avr:robotMotor", "--show-properties=unexpanded", "--format", "json")
out, _, err := cli.Run("board", "details", "-b", "arduino:avr:robotMotor", "--show-properties=unexpanded", "--json")
require.NoError(t, err)
jsonOut := requirejson.Parse(t, out)
jsonOut.MustContain(`{
Expand All @@ -131,7 +131,7 @@ func TestHardwareLoading(t *testing.T) {

{
// Also test local boards.txt properties override
out, _, err := cli.Run("board", "details", "-b", "arduino:avr:diecimila", "--show-properties=unexpanded", "--format", "json")
out, _, err := cli.Run("board", "details", "-b", "arduino:avr:diecimila", "--show-properties=unexpanded", "--json")
require.NoError(t, err)
jsonOut := requirejson.Parse(t, out)
jsonOut.MustContain(`{
Expand All @@ -152,7 +152,7 @@ func TestHardwareLoading(t *testing.T) {
require.NoError(t, customHwDir.CopyDirTo(cli.SketchbookDir().Join("hardware")))

{
out, _, err := cli.Run("core", "list", "--format", "json")
out, _, err := cli.Run("core", "list", "--json")
require.NoError(t, err)
jsonOut := requirejson.Parse(t, out)
jsonOut.Query(`.platforms | length`).LengthMustEqualTo(3)
Expand Down Expand Up @@ -217,7 +217,7 @@ func TestHardwareLoading(t *testing.T) {

{
// Also test local platform.txt properties override
out, _, err := cli.Run("board", "details", "-b", "arduino:avr:uno", "--format", "json")
out, _, err := cli.Run("board", "details", "-b", "arduino:avr:uno", "--json")
require.NoError(t, err)
jsonOut := requirejson.Parse(t, out)
jsonOut.MustContain(`{
Expand All @@ -244,7 +244,7 @@ func TestHardwareLoading(t *testing.T) {
}

{
out, _, err := cli.Run("board", "details", "-b", "arduino:avr:yun", "--show-properties=unexpanded", "--format", "json")
out, _, err := cli.Run("board", "details", "-b", "arduino:avr:yun", "--show-properties=unexpanded", "--json")
require.NoError(t, err)
jsonOut := requirejson.Parse(t, out)
jsonOut.MustContain(`{
Expand Down
8 changes: 4 additions & 4 deletions internal/integrationtest/compile_1/compile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func compileWithSimpleSketchCustomEnv(t *testing.T, env *integrationtest.Environ
require.NoError(t, err)

// Build sketch for arduino:avr:uno with json output
stdout, _, err = cli.RunWithCustomEnv(customEnv, "compile", "-b", fqbn, sketchPath.String(), "--format", "json")
stdout, _, err = cli.RunWithCustomEnv(customEnv, "compile", "-b", fqbn, sketchPath.String(), "--json")
require.NoError(t, err)
// check is a valid json and contains requested data
var compileOutput map[string]interface{}
Expand Down Expand Up @@ -516,7 +516,7 @@ func compileWithExportBinariesConfig(t *testing.T, env *integrationtest.Environm
defer cli.WorkingDir().Join("arduino-cli.yaml").Remove()

// Test if arduino-cli config file written in the previous run has the `always_export_binaries` flag set.
stdout, _, err := cli.Run("config", "dump", "--format", "json", "--config-file", "arduino-cli.yaml")
stdout, _, err := cli.Run("config", "dump", "--json", "--config-file", "arduino-cli.yaml")
require.NoError(t, err)
requirejson.Contains(t, stdout, `
{
Expand Down Expand Up @@ -845,7 +845,7 @@ func TestCompileWithArchivesAndLongPaths(t *testing.T) {
_, _, err = cli.Run("lib", "install", "ArduinoIoTCloud", "--config-file", "arduino-cli.yaml")
require.NoError(t, err)

stdout, _, err := cli.Run("lib", "examples", "ArduinoIoTCloud", "--format", "json", "--config-file", "arduino-cli.yaml")
stdout, _, err := cli.Run("lib", "examples", "ArduinoIoTCloud", "--json", "--config-file", "arduino-cli.yaml")
require.NoError(t, err)
libOutput := strings.Trim(requirejson.Parse(t, stdout).Query(`.examples.[0].library.install_dir`).String(), `"`)
sketchPath := paths.New(libOutput)
Expand Down Expand Up @@ -1189,7 +1189,7 @@ void loop() {
`
expected = strings.ReplaceAll(expected, "%SKETCH_PATH%", cpp.QuoteString(sketchPath.Join("SketchSimple.ino").String()))

jsonOut, _, err := cli.Run("compile", "-b", fqbn, "--preprocess", sketchPath.String(), "--format", "json")
jsonOut, _, err := cli.Run("compile", "-b", fqbn, "--preprocess", sketchPath.String(), "--json")
require.NoError(t, err)
var ex struct {
CompilerOut string `json:"compiler_out"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestCompileCommandsJSONGeneration(t *testing.T) {
require.NoError(t, err)

// Create a test sketch
out, _, err := cli.Run("sketch", "new", "Test", "--format", "json")
out, _, err := cli.Run("sketch", "new", "Test", "--json")
require.NoError(t, err)
var s struct {
Path string `json:"sketch_path"`
Expand Down
Loading

0 comments on commit e883b64

Please sign in to comment.