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

--json Outputs JSON objects for --nodes, --request-telemetry/position #577

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

aikomastboom
Copy link

In a attempt to make the output of meshtastic a bit more machine parsing friendly (eg by nushell) I propose the addition of '--json' to switch the output to something easily parsable when piped on the commandline.

@CLAassistant
Copy link

CLAassistant commented May 16, 2024

CLA assistant check
All committers have signed the CLA.

@holdenweb
Copy link
Contributor

Am I alone in thinking that any output produced in the presence of a --json option should actually be readable as a JSON document? I'm quite happy for other formats to exist, but please let's not mangle existing standards. Transforming JSON is a straightforward task, for which many support libraries exist. Parsing invented almost-JSON formats isn't.

@ianmcorvidae
Copy link
Contributor

It appears that these formats are, in fact, JSON (everything is produced via json.dumps) and could be treated as such.

However, they do look fairly ad-hoc and I think we need a consistent approach, as we're discussing over in #569 -- the discussed plan there so far has largely been to do as little modification of protobufs as we can other than turning them to JSON, and to identify things by the (lowercased) name of the protobuf. This will probably require a bit of internal refactoring for some things (e.g. I don't believe right now we're holding onto a copy of the actual NodeInfo protobufs for nodes, but packing into our own structure instead), but would be much more easily extensible to any other commands and straightforwardly documented in terms of the protobuf definitions.

@aikomastboom
Copy link
Author

I totally agree.. it would be preferred to eliminate conversions back and forth into JSON like this. Refactoring the whole codebase to facilitate a clear separation of concern / interface was not my intention. I guess It's best to close this PR and keep the effort to myself while a proper solution is drafted in Discussion: machine-readable 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.

4 participants