Skip to content

Conversation

@juergenRe
Copy link

Content, Request

In issue #862 a request was formulated to return the result of --info command in JSON or YAML format instead of current textual format, which is not machine readable. (I believe there was also another issue opened like this).

While the issue #862 goes further in asking some instaneous return of actual device metrics and telemetry data, this PR only covers the return format part.

Solution description

The solution reuses the approach from PR #867 in adding a --fmt parameter in the meshtastic call, this time used as a modifier for the --info command.

From a design point of view, I separated the data aspect (what will be shown) from the formatting aspect (how the data will be presented). Thus, the interface and node classes will only return data dictionaries which then can be treated further. Any addition or change in formatting will never introduce a change in node or interface classes.

Formatting is externalized in separate classes, using a factory pattern to instantiate the formatting class.

The call in __main__.py now is fully generic, adding a new formatter like yaml will also not affect this part of the code.

Testing

  • All unit tests have been updated so they reflect the new structure and test things correctly
  • The formatter classes got new unit tests, based on sample json data files creating different sets of data simulating the return data from node or interface.
  • Unit and integration tests pass 100%. I did not run smoke tests, because most of them anyway fail, so the result is not meaningful.

…t in a machine readable format.

Actually, change gives the same result as before.
fix unit tests related to introduction of formatter
adding fullSequence test to have a closed data flow from node/interface till formatted output
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.

1 participant