-
Notifications
You must be signed in to change notification settings - Fork 22
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
CLI commands with object results print js-but-not-json #12
Comments
I think it makes sense to return actual js-objects, as you might want to continue working with them inside the CLI. |
The point here is, that you get a js object as a |
@PostCrafter returning actual js-objects would be an improvement. All we're seeing here is the stringification of the object. If it was in JSON, it would still be valid JS, but as things sit now it's valid JS without being valid JSON. |
I agree, the current JS objects are fine, if you need json then append |
@ags131 what does the current output gain us? Why would you want to stringify js objects in a way that isn't json? |
The CLI is not meant for scripting, its meant for human interaction and uses simple, human readable output. theres no need for JSON, rather than wrapping the CLI in tools, its much more effective to write a mod and interface directly with the DB (Or if using screepsmod-mongo, you can just interact with mongo/redis directly) |
Would switching to JSON make it less human readable? We're just talking about putting quotes around strings. |
The advantage of using the CLI interface is having a standard way how to interact with the server independently on the storage backend. |
For my own edification, and because it might shed light on this dispute, can anyone pinpoint the code where the js object is getting turned into a string? I was unable to find it; the layout of the CLI code stumped me. The contents of that line and/or its location might add some perspective to this matter. |
As a counterpoint, I regularly use the CLI via telnet on machines without screeps installed, requiring a client to get the nicer output would remove that ease of use. |
I am at a loss for figuring out how that code works, where util.inspect comes from, or what callback that function is being called with. Somewhere there is a block of code that turns a JS object into the string quoted in my original post here. I'd like to find that block. |
backend-local/lib/cli/server.js Line 22 in 785013d
|
Oh, I see, util is a node library. https://nodejs.org/api/util.html#util_util_inspect_object_options |
|
So, I guess my question here is... Why |
|
That's a depressingly good answer :( |
It would be a lot easier to have other programs interact with the CLI if this response was valid JSON instead of just valid JS. I think the only change would be to use double quotes, and to quote the keys.
This could be a problem with lokijs. I wasn't able to follow the behavior of the CLI code far enough to find out.
The text was updated successfully, but these errors were encountered: