arduino-cli
arduino-cli copied to clipboard
Missing handling of new output formats
trafficstars
Bug Report
Current behavior
Some output is not printed in the format specified by the user when they use the new jsonmini or yaml options (https://github.com/arduino/arduino-cli/pull/1586, https://github.com/arduino/arduino-cli/pull/1600) with the --format flag.
This misformatted output breaks machine readability.
For example:
$ arduino-cli version
arduino-cli.exe Version: nightly-20220124 Commit: 530e671 Date: 2022-01-24T01:28:27Z
$ arduino-cli lib search --format jsonmini Arduino_MKRRGB
Updating index: library_index.json.gz downloaded ? 18677.76% 00m02ss
Updating index: library_index.json.sig downloaded
{"libraries":[{"name":"Arduino_MKRRGB","releases":{"1.0.0":{"author":"Arduino","version":"1.0.0","maintainer":"Arduino \[email protected]\u003e","sentence":"Allows you to draw on your MKR RGB shield.","paragraph":"Depends on the ArduinoGraphics library.","website":"http://github.com/arduino-libraries/Arduino_MKRRGB","category":"Display","architectures":["samd"],"types":["Arduino"],"resources":{"url":"https://downloads.arduino.cc/libraries/github.com/arduino-libraries/Arduino_MKRRGB-1.0.0.zip","archive_filename":"Arduino_MKRRGB-1.0.0.zip","checksum":"SHA-256:0c16c5db92467d65123b4fc16e0d3838d38c26da9137f2c50f3aa0cd17115b4d","size":7797,"cache_path":"libraries"},"provides_includes":["Arduino_MKRRGB.h"],"dependencies":[{"name":"ArduinoGraphics"}]}},"latest":{"author":"Arduino","version":"1.0.0","maintainer":"Arduino \[email protected]\u003e","sentence":"Allows you to draw on your MKR RGB shield.","paragraph":"Depends on the ArduinoGraphics library.","website":"http://github.com/arduino-libraries/Arduino_MKRRGB","category":"Display","architectures":["samd"],"types":["Arduino"],"resources":{"url":"https://downloads.arduino.cc/libraries/github.com/arduino-libraries/Arduino_MKRRGB-1.0.0.zip","archive_filename":"Arduino_MKRRGB-1.0.0.zip","checksum":"SHA-256:0c16c5db92467d65123b4fc16e0d3838d38c26da9137f2c50f3aa0cd17115b4d","size":7797,"cache_path":"libraries"},"provides_includes":["Arduino_MKRRGB.h"],"dependencies":[{"name":"ArduinoGraphics"}]}}],"status":1}
$ arduino-cli lib search --format jsonmini Arduino_MKRRGB | jq '.libraries[0].latest.version'
jq: error (at <stdin>:1): Cannot index number with string "libraries"
parse error: Invalid numeric literal at line 1, column 6
$ arduino-cli lib search --format json Arduino_MKRRGB | jq '.libraries[0].latest.version'
"1.0.0"
$ arduino-cli lib search --format yaml Arduino_MKRRGB
Updating index: library_index.json.gz downloaded ? 19660.80% 00m02ss
Updating index: library_index.json.sig downloaded
libraries:
- name: Arduino_MKRRGB
releases:
1.0.0:
author: Arduino
version: 1.0.0
maintainer: Arduino <[email protected]>
sentence: Allows you to draw on your MKR RGB shield.
paragraph: Depends on the ArduinoGraphics library.
website: http://github.com/arduino-libraries/Arduino_MKRRGB
category: Display
architectures:
- samd
types:
- Arduino
resources:
url: https://downloads.arduino.cc/libraries/github.com/arduino-libraries/Arduino_MKRRGB-1.0.0.zip
archivefilename: Arduino_MKRRGB-1.0.0.zip
checksum: SHA-256:0c16c5db92467d65123b4fc16e0d3838d38c26da9137f2c50f3aa0cd17115b4d
size: 7797
cachepath: libraries
license: ""
providesincludes:
- Arduino_MKRRGB.h
dependencies:
- name: ArduinoGraphics
versionconstraint: ""
latest:
author: Arduino
version: 1.0.0
maintainer: Arduino <[email protected]>
sentence: Allows you to draw on your MKR RGB shield.
paragraph: Depends on the ArduinoGraphics library.
website: http://github.com/arduino-libraries/Arduino_MKRRGB
category: Display
architectures:
- samd
types:
- Arduino
resources:
url: https://downloads.arduino.cc/libraries/github.com/arduino-libraries/Arduino_MKRRGB-1.0.0.zip
archivefilename: Arduino_MKRRGB-1.0.0.zip
checksum: SHA-256:0c16c5db92467d65123b4fc16e0d3838d38c26da9137f2c50f3aa0cd17115b4d
size: 7797
cachepath: libraries
license: ""
providesincludes:
- Arduino_MKRRGB.h
dependencies:
- name: ArduinoGraphics
versionconstraint: ""
status: 1
The code here does not handle the new formats:
https://github.com/arduino/arduino-cli/blob/530e671e34f80dbf4366a63946460cfbcee8e068/cli/output/rpc_progress.go#L36
Expected behavior
All output is printed in the specified format.
Environment
- CLI version: nightly-20220124 Commit: 530e671 Date: 2022-01-24T01:28:27Z
- OS and platform: Windows 10
Additional context
Originally reported (peripherally) at https://github.com/arduino/arduino-cli/issues/1624