Closed Renaud11232 closed 1 year ago
I looked into this (I was just curious) and the issue is that since the simplification of outdated
command (commit here, by @cmaglie), what the code is doing is first to list the core packages that are upgradable (same as arduino-cli core list --updatable
) and then libraries that are upgradable (./arduino-cli lib list --updatable
).
And while this works nicely for the text format, it does not produce valid JSON, because it just prints two separate JSON objects (in your example, an empty []
for core packages and then the libraries part).
The fix that I can think of is refactor a bit the code so that internal/cli/outdated
can get the slices returned from both internal/cli/core
and internal/cli/lib
packages, have its own implementation of Result interface
and call feedback.PrintResult
directly with the appended slices.
@cmaglie, can you please comment on my suggestion? Thanks!
The fix that I can think of is refactor a bit the code so that internal/cli/outdated can get the slices returned from both internal/cli/core and internal/cli/lib packages, have its own implementation of Result interface and call feedback.PrintResult directly with the appended slices.
That's correct, but I don't know how much refactoring is required to do so. I see that you made a PR already, I guess you tried implementing the idea above, I'll take a look at it ASAP.
@cmaglie Thanks! Yes, I got started before your feedback as it seemed quite right. The PR is ready for review now :mag:
Describe the problem
When running the
outdated
command with--format json
, the produced output is not valid JSON. It looks like it contains two arrays.To reproduce
Install an outdated library ie:
Then run :
Which produces the following output :
Expected behavior
The output should be valid JSON.
Arduino CLI version
arduino-cli.exe Version: nightly-20230310 Commit: fed439a Date: 2023-03-10T01:35:49Z
Operating system
Windows
Operating system version
Windows 11 22H2
Additional context
No response
Issue checklist