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

Fix output for aleph query --includeData #189

Merged
merged 5 commits into from
Mar 1, 2017
Merged

Conversation

yusefnapora
Copy link
Contributor

I noticed on Friday that the recent Statement class refactor in #177 broke the output of the aleph query command if you use it with the --includeData flag. The "expanded" object body is included when you call inspect, but not when you try to print the Statement object as JSON.

So this PR changes the way we override the depth of the inspect call. Instead of doing it in the Statement.inspect method, we just return the JS object we want to print from Statement.inspect, and override the default inspect depth in the repl command. That way, in the aleph query command, we can call .inspect() on the query result and print it, including the embedded object.

This is much cleaner anyway, since how you format the output shouldn't be tied to the Statement class. I think when I wrote the earlier impl I hadn't discovered that you can override util.inspect.defaultOptions

- we were returning a formatted string (using util.inspect), but
that makes it more difficult to re-use the inspect output elsewhere.
Copy link
Contributor

@parkan parkan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this is much better :)

@yusefnapora yusefnapora merged commit 3074c7f into master Mar 1, 2017
@yusefnapora yusefnapora deleted the yn-aleph-query-fix branch March 1, 2017 17:33
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.

2 participants