Add Optional Summary of File Types and their Count#10
Merged
Speedrunyourknowledge merged 5 commits intomainfrom Dec 1, 2025
Merged
Add Optional Summary of File Types and their Count#10Speedrunyourknowledge merged 5 commits intomainfrom
Speedrunyourknowledge merged 5 commits intomainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR resolves #8 and #9. This closes user story #3.
What this PR Does
When the user runs Magika in the CLI, they now have the option of providing a --summary flag.
If this flag is active (and the --json flag is not active), then Magika's normal output will be followed by a list of detected file types and their count.
Implementation
I updated the Rust source file
rust/cli/src/main.rsto keep track of how many times each file type was detected.I configured the summary list to display in order of descending file count, followed by alphabetical order. I also color coded each file type to match the colors in Magika's normal output.
To use the modified Rust file rather than the pre-packaged Rust binary, I ran
cargo run <my_file>in the CLI instead ofmagika <my_file>.How This Was Tested
From within the
rust/clidirectory, I rancargo +nightly fmt -- --checkto ensure my code syntactically matches the existing code. I also ran./test.shto ensure my code passes the unit tests.Screenshots
Output of
cargo run -- --recursive --summary ../../tests_data