Description
Describe the problem
In the JSON output, the fields that are gRPC enumerations are not properly encoded because in the JSON is presented the internal enumeration value instead of the meaning of the enumeration.
To reproduce
For example lib list --format json
has the location
and layout
fields (marked with the arrow) that are not really understandable:
{
"library": {
"name": "Servo",
"author": "Michael C. Miller",
"maintainer": "GitHub/esp8266/arduino",
"sentence": "Allows Esp8266 boards to control a variety of servo motors.",
"paragraph": "This library can control a great number of servos.\u003cbr /\u003eIt makes careful use of timers: the library can control 12 servos using only 1 timer.\u003cbr /\u003e",
"website": "http://arduino.cc/en/Reference/Servo",
"category": "Device Control",
"architectures": [
"esp8266"
],
"install_dir": "/home/megabug/.arduino15/packages/esp8266/hardware/esp8266/3.1.1/libraries/Servo",
"source_dir": "/home/megabug/.arduino15/packages/esp8266/hardware/esp8266/3.1.1/libraries/Servo/src",
"container_platform": "esp8266:esp8266@3.1.1",
"dot_a_linkage": true,
"version": "1.0.2",
"license": "Unspecified",
"location": 2, <-----
"layout": 1, <-----
"examples": [
"/home/megabug/.arduino15/packages/esp8266/hardware/esp8266/3.1.1/libraries/Servo/examples/Sweep"
],
"provides_includes": [
"Servo.h"
]
},
"release": {
"author": "Michael Margolis, Arduino",
"version": "1.2.1",
"maintainer": "Arduino \u003cinfo@arduino.cc\u003e",
"sentence": "Allows Arduino boards to control a variety of servo motors.",
"paragraph": "This library can control a great number of servos.\u003cbr /\u003eIt makes careful use of timers: the library can control 12 servos using only 1 timer.\u003cbr /\u003eOn the Arduino Due you can control up to 60 servos.",
"website": "https://www.arduino.cc/reference/en/libraries/servo/",
"category": "Device Control",
"architectures": [
"avr",
"megaavr",
"sam",
"samd",
"nrf52",
"stm32f4",
"mbed",
"mbed_nano",
"mbed_portenta",
"mbed_rp2040",
"renesas",
"renesas_portenta",
"renesas_uno"
],
"types": [
"Arduino"
]
}
}
The meaning of 1
and 2
are LibraryLocationPlatformBuiltin
and LibraryLayoutFlat
respectively, but this is not immediately clear without knowing the enumeration value.
Expected behavior
It would be better if the output is something like:
"location": "platform built-in",
"layout": "flat",
Arduino CLI version
nightly
Operating system
N/A
Operating system version
N/A
Additional context
The main issue is internally the CLI directly marshals the gRPC-generated structures, a better approach would be to copy the content of those structures into an intermediate Result
structure and marshal that one.
Issue checklist
- I searched for previous reports in the issue tracker
- I verified the problem still occurs when using the nightly build
- My report contains all necessary details