-
Notifications
You must be signed in to change notification settings - Fork 172
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
format-379: Add --report
command line argument to export json format report to given directory
#495
Conversation
…json report of which files have/would have been formatted
--report
command line argument to export json format report to given directory --report
command line argument to export json format report to given directory
Below is an example output of this change. Let me know if you'd prefer this be converted to camelCase.
|
@JoeRobich ptal |
@jpshrader looks like a fantastic start! Thanks for the controbution! I left a few comments and I want @JoeRobich to take a look before merging |
@@ -36,13 +36,14 @@ private static async Task<int> Main(string[] args) | |||
.AddOption(new Option(new[] { "--dry-run" }, Resources.Format_files_but_do_not_save_changes_to_disk, new Argument<bool>())) | |||
.AddOption(new Option(new[] { "--check" }, Resources.Terminate_with_a_non_zero_exit_code_if_any_files_were_formatted, new Argument<bool>())) | |||
.AddOption(new Option(new[] { "--files" }, Resources.A_comma_separated_list_of_relative_file_paths_to_format_All_files_are_formatted_if_empty, new Argument<string>(() => null))) | |||
.AddOption(new Option(new[] { "--report" }, Resources.Accepts_a_file_path_which_if_provided_will_produce_a_format_report_json_file_in_the_given_directory, new Argument<string>(() => null))) |
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.
If we made the default value ".", then if just the option is provided it would drop the report in the current folder.
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 think there may be difficulty distinguishing between providing an empty argument vs not providing the option at all (unless I'm missing something). Changing the default argument to "." will set 'reportPath` even if you don't provide the argument at all.
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.
Ah, good point.
@jpshrader Thanks for working on this. It is a good start to providing more report options such as patch file support. |
1. Add unit tests for Formatted Files behaviour 2. Use System.Text.Json 3. Path.Combine/StringBuilder and pathing options 4. Pass ref to list instead of returning tuple
@jpshrader looks good to me! If @JoeRobich signs off I'll merge it |
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.
Thanks so much for this. Just requesting a few changes before we merge it in. =)
@@ -36,13 +36,14 @@ private static async Task<int> Main(string[] args) | |||
.AddOption(new Option(new[] { "--dry-run" }, Resources.Format_files_but_do_not_save_changes_to_disk, new Argument<bool>())) | |||
.AddOption(new Option(new[] { "--check" }, Resources.Terminate_with_a_non_zero_exit_code_if_any_files_were_formatted, new Argument<bool>())) | |||
.AddOption(new Option(new[] { "--files" }, Resources.A_comma_separated_list_of_relative_file_paths_to_format_All_files_are_formatted_if_empty, new Argument<string>(() => null))) | |||
.AddOption(new Option(new[] { "--report" }, Resources.Accepts_a_file_path_which_if_provided_will_produce_a_format_report_json_file_in_the_given_directory, new Argument<string>(() => null))) |
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.
Ah, good point.
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.
LGTM!
@jmarolf do you have any final thoughts?
@JoeRobich looks good to merge to me! |
Awesome, thanks @JoeRobich / @jmarolf ! Appreciate the reviews! |
PR for this task. I diverged a tad from the original ask (generate a report when the
--dry-run
is provided) and decided that this would probably be useful in both normal and--dry-run
modes. Also allowed the user to provide the output directory for the report, which I felt would be handy too (e.g. publishing it to a report viewer in Jenkins).