Skip to content

Conversation

@Speedrunyourknowledge
Copy link
Owner

@Speedrunyourknowledge Speedrunyourknowledge commented Dec 1, 2025

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.rs to 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 of magika <my_file>.

How This Was Tested

From within the rust/cli directory, I ran cargo +nightly fmt -- --check to ensure my code syntactically matches the existing code. I also ran ./test.sh to ensure my code passes the unit tests.

Screenshots

Output of cargo run -- --recursive --summary ../../tests_data

sde 2 pr-1

@Speedrunyourknowledge Speedrunyourknowledge merged commit be6bc1b into main Dec 1, 2025
90 checks passed
@Speedrunyourknowledge Speedrunyourknowledge deleted the feature/file-type-count branch December 1, 2025 10:16
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.

Add function to count number of file types reported in a directory

2 participants