Skip to content

feat: add --output-format/-o tabular/csv/yaml/json arg#2

Merged
Maximkaaa merged 4 commits into
Maximkaaa:mainfrom
aznashwan:feat/output-format
Apr 19, 2026
Merged

feat: add --output-format/-o tabular/csv/yaml/json arg#2
Maximkaaa merged 4 commits into
Maximkaaa:mainfrom
aznashwan:feat/output-format

Conversation

@aznashwan

Copy link
Copy Markdown
Contributor

This patch adds support for selecting the output format using the
--output-format/-o arg.

Options include CSV, Json, YAML, as well as the pre-existing Tabular
format.

I've included some tests to ensure that the output serialization doesn't panic this time 🤣
That being said, I did not feel the need to add explicit tests on the output values/fields to avoid making adding fields a chore (except for the CSV implementation, which sadly inevitably requires some glue code).

Thanks again for making this crate!

@Maximkaaa Maximkaaa left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. And this time it doesn't panic! :-)

Just a few comments to make output look cleaner.

Comment thread src/main.rs Outdated
Comment thread src/output.rs Outdated
Comment thread src/output.rs Outdated
Comment thread src/output.rs Outdated
Comment thread src/output.rs
Comment thread Cargo.toml Outdated
Comment thread src/output.rs Outdated
OutputFormat::Csv => {
let mut writer = CsvWriter::from_writer(stdout());
csv_output::write_csv_header_row(&mut writer);
csv_output::write_single_csv_value(root_dir, stats, &mut writer);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes output of CSV for single and multiple files differ. For single it prints out "." as a path, and for multiple "Main". I think a better output would have "Total" in both cases, and in multi-file case make in the last line, not firstl. This would look like a proper spreadsheet.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've replaced the first column of the totals CSV output with the file count.

Comment thread src/output.rs Outdated
@Maximkaaa

Copy link
Copy Markdown
Owner

Also, please, add some information about this into readme.

@aznashwan aznashwan requested a review from Maximkaaa April 18, 2026 23:27
@aznashwan

Copy link
Copy Markdown
Contributor Author

Great points, should be addressed now, thanks for your patience and keen eye in examining the output! 😄

@Maximkaaa Maximkaaa left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good now, just one thing. CSV output has an extra empty line at the end of the output.

Also, I've configured release-plz, so that we can easily release the updated version so, please, rebase on main.

Signed-off-by: Nashwan Azhari <aznashwan@icloud.com>
This patch adds support for selecting the output format using the
`--output-format/-o` arg.

Options include CSV, Json, YAML, as well as the pre-existing Tabular
format.

Signed-off-by: Nashwan Azhari <aznashwan@icloud.com>
Signed-off-by: Nashwan Azhari <aznashwan@icloud.com>
Signed-off-by: Nashwan Azhari <aznashwan@icloud.com>
@aznashwan aznashwan force-pushed the feat/output-format branch from 3833b4d to 299f74f Compare April 19, 2026 09:55
@Maximkaaa Maximkaaa merged commit e88672c into Maximkaaa:main Apr 19, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants