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
feat(cli): generate multiple outputs to different files in a single c… #2011
feat(cli): generate multiple outputs to different files in a single c… #2011
Conversation
8f94078
to
2471805
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey!
My apologies for such a delayed review on this one.
I'm thinking we could perhaps do output.html
, output.junit
and so on?
Might cause less friction. What do you think?
I think we could simplify this even more by keeping the existing options with some extra syntax support:
WDYT @P0lip @albertored? |
@fgreinacher
However, I'm not certain about the syntax for the output if we went with the above convention.
|
@fgreinacher I also like it, it is similar to the one I originally suggested in the issue but more clear. |
I think @P0lip should have the last call on this 😀 |
Yes, sure, I forgot to tag him |
@albertored go for it if you have spare time! Thanks a lot for putting all the effort into it. |
2471805
to
7cfae07
Compare
@P0lip @fgreinacher done, let me know what do you think, the logic for handling those options is quite complex. I also have a lint error that I'm not able to fix...
|
expect(writeOutput).nthCalledWith(1, '<formatted output>', undefined); | ||
expect(writeOutput).nthCalledWith(2, '<formatted output>', 'foo.json'); | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we test error cases here? For example:
--format json,junit --output results.txt
(output needs to include format)--format json --output junit:results.xml
(unselected format in output)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I was waiting to have a feedback on the implementation first
@@ -20,8 +20,8 @@ Options: | |||
--version Show version number [boolean] | |||
--help Show help [boolean] | |||
-e, --encoding text encoding to use [string] [choices: "utf8", "ascii", "utf-8", "utf16le", "ucs2", "ucs-2", "base64", "latin1"] [default: "utf8"] | |||
-f, --format formatter to use for outputting results [string] [choices: "json", "stylish", "junit", "html", "text", "teamcity", "pretty"] [default: "stylish"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really like that we lost the choices
in the help text.
Wondering whether it would be easier (implementation- and usage-wise) to allow multiple --format
and --output
parameters instead of the providing multiple values within one parameter, e.g. --format stylish --format junit --output junit:junit.xml
instead of of --format stylish,junit --output junit:junit.xml
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initially, I was looking at having --format json junit
but yargs
does not behave well with array arguments together with positional ones.
Repeating the --format
flag is completely doable instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also consider https://github.com/yargs/yargs/blob/main/docs/tricks.md#objects to make the implementation even easier (e.g. --output.junit junit.xml
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup, it feels like using objects might be a good idea for outputs.
I'm trying to explore how invasive changing the type of format
option would be.
It feels like we'd need to consider it a breaking change if we changed the type of the option, as yargs
would need to be instrumented with --
to stop the parsing, or, alternatively, pass format
after the positional arguments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thoughts #2037?
Closing this one as we've already merged #2037. |
Fixes #1970 .
Checklist
Does this PR introduce a breaking change?