Skip to content

Commit 9dbd440

Browse files
committed
Merge pull request rust-lang#12 from thomassnielsen/help-json-output
Add option for JSON output to help command
2 parents 7f5a4bf + 3456274 commit 9dbd440

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

text/0000-help-json-output.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
- Start Date: 2015-05-16
2+
- RFC PR: (leave this empty)
3+
- ember-cli Issue: (leave this empty)
4+
5+
# Summary
6+
7+
This has come up in [#3699](https://github.com/ember-cli/ember-cli/issues/3699) and [EmberTown/ember-hearth/#66](https://github.com/EmberTown/ember-hearth/issues/66).
8+
9+
In short, it would be nice for tools that depend on Ember-CLI to be able to read the help output as JSON (for example `ember g --help --json`).
10+
11+
# Motivation
12+
13+
In our specific use case in [Ember Hearth](https://github.com/EmberTown/ember-hearth/) we would like to be able to render a dynamic GUI for some tasks, like generating blueprints. This way we could also include any blueprints added by addons. This will also apply to any other tools interfacing with Ember-CLI.
14+
15+
# Detailed design
16+
We should probably make the internal help-functions (like `printBasicHelp` and `printDetailedHelp`) use JSON internally, and parse to human readable before printing (unless `--json` is specified).
17+
18+
I'm imagining the json output would be something like this:
19+
20+
```json
21+
{
22+
"name":"generate",
23+
"description":"Generates new code from blueprints.",
24+
"aliases":["g"],
25+
"flags":[
26+
{
27+
"flag":"--verbose",
28+
"aliases":["-v"],
29+
"description":"Verbose output"
30+
}, {}],
31+
"commands":[
32+
{
33+
"command":"template",
34+
"description":"Generates a template.",
35+
"arguments":["name"]
36+
},
37+
{
38+
"command":"model",
39+
"description":"Generate an ember-data model.",
40+
"arguments":[
41+
"name",
42+
{
43+
"argument":"attr:type",
44+
"description":"Add attributes to the model, e.g. 'name:String age:Number'",
45+
"multiple":true
46+
}]
47+
}, {}]
48+
}
49+
```
50+
51+
Note that this output contains a bit more info than the current --help, specifically in the attr:type argument for the model command. This is something I feel is currently missing (I did not understand the model generator command without consulting a colleague, for example), and would be nice to add while we're at it.
52+
53+
It should be pretty straight forward to generate a human readable output from this JSON. There are a few things missing: However: The generate help command specifically groups commands by addon. I'm not sure how this should be accomplished, and if this matches the other help outputs. Ideally, any tools reading the JSON should be able to rely on the format being the same for all commands. This would keep the internals cleaner as well, including the human readable parser.
54+
55+
# Drawbacks
56+
57+
* Requires rewrite of help methods, possibly also for some addons (unless we can provide backwards compatability)
58+
* Increases codebase size
59+
60+
# Alternatives
61+
62+
* We could standardize help output enough that it can be safely regexed by other tools
63+
* We could not do this, and require any tools to update whenever Ember-CLI changes any commands
64+
65+
# Unresolved questions
66+
67+
* Internal architecture specifics (rewrite printBasicHelp or create a new setup, etc)
68+
* Specifying JSON format details
69+
* List any dependencies, like docs, that will need to be updated with this change

0 commit comments

Comments
 (0)