Skip to content
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

Add minified json output format #1586

Merged
merged 1 commit into from
Dec 7, 2021
Merged

Conversation

silvanocerza
Copy link
Contributor

Please check if the PR fulfills these requirements

  • The PR has no duplicates (please search among the Pull Requests
    before creating one)
  • The PR follows
    our contributing guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • UPGRADING.md has been updated with a migration guide (for breaking changes)
  • What kind of change does this PR introduce?

Adds a new output format.

  • What is the current behavior?

The arduino-cli supports two output formats as of now: text (default) and json.
json is always pretty printed, this might make it difficult for some to parse it correctly, it also make the output much more longer than necessary with lots of empty space.

  • What is the new behavior?

The arduino-cli now supports three output formats as of now: text (default), json and jsonmini.

Example output:

$ arduino-cli board list
Port         Protocol Type              Board Name                FQBN             Core
/dev/ttyACM0 serial   Unknown
/dev/ttyACM1 serial   Serial Port (USB) Arduino Mega or Mega 2560 arduino:avr:mega arduino:avr


$ arduino-cli board list --format json
[
  {
    "port": {
      "address": "/dev/ttyACM0",
      "label": "/dev/ttyACM0",
      "protocol": "serial",
      "protocol_label": "Serial Port (USB)",
      "properties": {
        "pid": "0x5385",
        "serialNumber": "HTK32",
        "vid": "0x27c6"
      }
    }
  },
  {
    "matching_boards": [
      {
        "name": "Arduino Mega or Mega 2560",
        "fqbn": "arduino:avr:mega"
      }
    ],
    "port": {
      "address": "/dev/ttyACM1",
      "label": "/dev/ttyACM1",
      "protocol": "serial",
      "protocol_label": "Serial Port (USB)",
      "properties": {
        "pid": "0x0242",
        "serialNumber": "85438303133351C080B1",
        "vid": "0x2341"
      }
    }
  }
]

$ arduino-cli board list --format jsonmini
[{"port":{"address":"/dev/ttyACM0","label":"/dev/ttyACM0","protocol":"serial","protocol_label":"Serial Port (USB)","properties":{"pid":"0x5385","serialNumber":"HTK32","vid":"0x27c6"}}},{"matching_boards":[{"name":"Arduino Mega or Mega 2560","fqbn":"arduino:avr:mega"}],"port":{"address":"/dev/ttyACM1","label":"/dev/ttyACM1","protocol":"serial","protocol_label":"Serial Port (USB)","properties":{"pid":"0x0242","serialNumber":"85438303133351C080B1","vid":"0x2341"}}}]

Nope.

  • Other information:

Fixes #1584.


See how to contribute

@silvanocerza silvanocerza merged commit 9b6f769 into master Dec 7, 2021
@silvanocerza silvanocerza deleted the scerza/json-mini-format branch December 7, 2021 16:09
umbynos pushed a commit that referenced this pull request Dec 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

There should be the option to have minified json as output
2 participants