dequelabs / axe-cli

[Deprecated] A command-line interface for the aXe accessibility testing engine
Mozilla Public License 2.0
430 stars 44 forks source link

Output JSON without saving it as a file #15

Closed jaimeiniesta closed 5 years ago

jaimeiniesta commented 7 years ago

Currently axe-cli has the --save option to save the results to a file. This is great but it could also be helpful to have an option to directly output this JSON to stdout.

This can simplify integrating axe-cli in web services that take an URL to test, and return the JSON results - without needing to save to disk, read that file to return its contents and then removing the file.

This is what we did in accesslint:

https://github.com/accesslint/accesslint-cli.js/pull/16

I can submit a PR to add this if it sounds OK to you.

WilcoFiers commented 7 years ago

Sounds good. Do you have any suggestions? Maybe something like --dump?

jaimeiniesta commented 7 years ago

How about --format=json?

jaimeiniesta commented 7 years ago

...or maybe just --dump, as there are no plans to add other formats like XML or CSV I guess.

WilcoFiers commented 7 years ago

Maybe we should use --reporter. Axe-core has a few different reporters you could use, that way you get those features too.

jaimeiniesta commented 7 years ago

I've sent a PR so we can discuss over the code. By now we have a first working version that adds an option:

-j, --json-dump Output the results directly as JSON, without saving to a file

I went for this as -d is already used for --dir, and because it's more explicit about the format.

Now, the thing with index.js currently is that there are many console.log everywhere that need to be silenced in this case, so that we only produce JSON output.

I'll try to clean this up by using a logger that will know if it should stay quiet in this situation.

marcysutton commented 6 years ago

@jaimeiniesta what's the status of this–were you going to add a PR?

jaimeiniesta commented 6 years ago

@marcysutton I started with this and there's a PR https://github.com/dequelabs/axe-cli/pull/17

But later I abandoned the idea due to lack of time to do that properly, sorry. So it's OK to close this issue or someone else pick it.

WilcoFiers commented 6 years ago

I think we can pick this issue up ourselves. I've been working on an update for axe-cli, to get rid of PhantomJS and to run axe 3.0.