commit 7f831ba44d8d071a4ae1145aa460868ac06f1516 Author: Cole Speelman Date: Thu Jan 22 16:28:43 2026 -0500 Initial GPL-3.0 Release (v1.0.0) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4f96631 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/target +/dist diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..2ac0691 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,22 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [1.0.0] - 2026-01-22 + +This stable release marks the official launch of `sized` under the GNU General Public License v3.0. + +### Added +- **Fast & Concurrent Analysis**: Multi-threaded directory traversal using `rayon` and `ignore`. +- **Physical vs. Logical Distinction**: Accurate reporting of **Apparent Size** vs. **Disk Usage** (blocks). +- **Unit & Precision Control**: Configurable unit systems (Binary/Decimal) and decimal precision. +- **Advanced Filtering**: Filter by directory depth and minimum file size. +- **Sorting**: Flexible sorting by name, type, size, or blocks. +- **Gitignore Support**: Native support for `.gitignore` and `.ignore` files. +- **Exporting**: Support for CSV and NDJSON output formats. +- **Documentation**: Comprehensive standard Unix man pages and a detailed user guide. +- **Shell Completions**: Automatic generation for Bash, Zsh, and Fish. +- **Licensing**: GPL-3.0 to ensure the tool remains a shared public resource. \ No newline at end of file diff --git a/CLA.md b/CLA.md new file mode 100644 index 0000000..35fd482 --- /dev/null +++ b/CLA.md @@ -0,0 +1,60 @@ +# 📄 Contributor License Agreement (CLA) + +You can use this **as-is**. It is intentionally plain and strong. + +--- + +## Contributor License Agreement + +By contributing to this project (“Project”), you (“Contributor”) agree to the following terms: + +### 1. Grant of Copyright License + +You hereby grant to the Project Maintainer a **perpetual, worldwide, non-exclusive, irrevocable, royalty-free, transferable, and sublicensable license** to use, reproduce, modify, prepare derivative works of, publicly display, publicly perform, distribute, and otherwise exploit your contributions, in whole or in part, in any form and for any purpose. + +This includes, but is not limited to, the right to **relicense the Project or your contributions under any license**, including proprietary or commercial licenses. + +--- + +### 2. Grant of Patent License + +You hereby grant to the Project Maintainer a **perpetual, worldwide, non-exclusive, irrevocable, royalty-free patent license** to make, have made, use, offer to sell, sell, import, and otherwise transfer your contributions, where such license applies to any patent claims you own or control that are necessarily infringed by your contribution. + +--- + +### 3. Ownership + +You retain ownership of your contributions. This Agreement does **not** transfer copyright ownership to the Project Maintainer. + +--- + +### 4. Original Work or Right to Contribute + +You represent that: + +* Your contributions are your original work, **or** +* You have the legal right to submit them under these terms. + +You agree not to submit contributions that are encumbered by incompatible licenses, employment agreements, or other legal restrictions. + +--- + +### 5. No Obligation to Accept Contributions + +The Project Maintainer is under **no obligation** to accept, merge, or distribute any contributions. + +--- + +### 6. No Warranty + +Your contributions are provided **“as is”**, without warranty of any kind, express or implied. + +--- + +### 7. Governing Law + +This Agreement shall be governed by and construed in accordance with the laws of **Canada**, without regard to conflict-of-law principles. + +--- + +By submitting a contribution (including code, documentation, or other materials), you acknowledge that you have read and agree to the terms of this Contributor License Agreement. diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..16b90fa --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,1675 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "ahash" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" +dependencies = [ + "getrandom 0.2.17", + "once_cell", + "version_check", +] + +[[package]] +name = "aho-corasick" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" +dependencies = [ + "memchr", +] + +[[package]] +name = "anes" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" + +[[package]] +name = "anstream" +version = "0.6.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43d5b281e737544384e969a5ccad3f1cdd24b48086a0fc1b2a5262a26b8f4f4a" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78" + +[[package]] +name = "anstyle-parse" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d" +dependencies = [ + "anstyle", + "once_cell_polyfill", + "windows-sys 0.61.2", +] + +[[package]] +name = "arrayvec" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" + +[[package]] +name = "assert_cmd" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c5bcfa8749ac45dd12cb11055aeeb6b27a3895560d60d71e3c23bf979e60514" +dependencies = [ + "anstyle", + "bstr", + "libc", + "predicates", + "predicates-core", + "predicates-tree", + "wait-timeout", +] + +[[package]] +name = "autocfg" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" + +[[package]] +name = "bitflags" +version = "2.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3" + +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + +[[package]] +name = "borsh" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1da5ab77c1437701eeff7c88d968729e7766172279eab0676857b3d63af7a6f" +dependencies = [ + "borsh-derive", + "cfg_aliases", +] + +[[package]] +name = "borsh-derive" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0686c856aa6aac0c4498f936d7d6a02df690f614c03e4d906d1018062b5c5e2c" +dependencies = [ + "once_cell", + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 2.0.114", +] + +[[package]] +name = "bstr" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63044e1ae8e69f3b5a92c736ca6269b8d12fa7efe39bf34ddb06d102cf0e2cab" +dependencies = [ + "memchr", + "regex-automata", + "serde", +] + +[[package]] +name = "bumpalo" +version = "3.19.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dd9dc738b7a8311c7ade152424974d8115f2cdad61e8dab8dac9f2362298510" + +[[package]] +name = "byte-unit" +version = "5.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c6d47a4e2961fb8721bcfc54feae6455f2f64e7054f9bc67e875f0e77f4c58d" +dependencies = [ + "rust_decimal", + "schemars", + "serde", + "utf8-width", +] + +[[package]] +name = "bytecheck" +version = "0.6.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23cdc57ce23ac53c931e88a43d06d070a6fd142f2617be5855eb75efc9beb1c2" +dependencies = [ + "bytecheck_derive", + "ptr_meta", + "simdutf8", +] + +[[package]] +name = "bytecheck_derive" +version = "0.6.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3db406d29fbcd95542e92559bed4d8ad92636d1ca8b3b72ede10b4bcc010e659" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "bytes" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b35204fbdc0b3f4446b89fc1ac2cf84a8a68971995d0bf2e925ec7cd960f9cb3" + +[[package]] +name = "cast" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" + +[[package]] +name = "cfg-if" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" + +[[package]] +name = "cfg_aliases" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" + +[[package]] +name = "ciborium" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42e69ffd6f0917f5c029256a24d0161db17cea3997d185db0d35926308770f0e" +dependencies = [ + "ciborium-io", + "ciborium-ll", + "serde", +] + +[[package]] +name = "ciborium-io" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05afea1e0a06c9be33d539b876f1ce3692f4afea2cb41f740e7743225ed1c757" + +[[package]] +name = "ciborium-ll" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57663b653d948a338bfb3eeba9bb2fd5fcfaecb9e199e87e1eda4d9e8b240fd9" +dependencies = [ + "ciborium-io", + "half", +] + +[[package]] +name = "clap" +version = "4.5.54" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6e6ff9dcd79cff5cd969a17a545d79e84ab086e444102a591e288a8aa3ce394" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.54" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa42cf4d2b7a41bc8f663a7cab4031ebafa1bf3875705bfaf8466dc60ab52c00" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_complete" +version = "4.5.65" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "430b4dc2b5e3861848de79627b2bedc9f3342c7da5173a14eaa5d0f8dc18ae5d" +dependencies = [ + "clap", +] + +[[package]] +name = "clap_derive" +version = "4.5.49" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a0b5487afeab2deb2ff4e03a807ad1a03ac532ff5a2cee5d86884440c7f7671" +dependencies = [ + "heck 0.5.0", + "proc-macro2", + "quote", + "syn 2.0.114", +] + +[[package]] +name = "clap_lex" +version = "0.7.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3e64b0cc0439b12df2fa678eae89a1c56a529fd067a9115f7827f1fffd22b32" + +[[package]] +name = "clap_mangen" +version = "0.2.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ea63a92086df93893164221ad4f24142086d535b3a0957b9b9bea2dc86301" +dependencies = [ + "clap", + "roff", +] + +[[package]] +name = "colorchoice" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" + +[[package]] +name = "colored" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "117725a109d387c937a1533ce01b450cbde6b88abceea8473c4d7a85853cda3c" +dependencies = [ + "lazy_static", + "windows-sys 0.59.0", +] + +[[package]] +name = "comfy-table" +version = "7.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "958c5d6ecf1f214b4c2bbbbf6ab9523a864bd136dcf71a7e8904799acfe1ad47" +dependencies = [ + "crossterm", + "unicode-segmentation", + "unicode-width", +] + +[[package]] +name = "criterion" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2b12d017a929603d80db1831cd3a24082f8137ce19c69e6447f54f5fc8d692f" +dependencies = [ + "anes", + "cast", + "ciborium", + "clap", + "criterion-plot", + "is-terminal", + "itertools", + "num-traits", + "once_cell", + "oorandom", + "plotters", + "rayon", + "regex", + "serde", + "serde_derive", + "serde_json", + "tinytemplate", + "walkdir", +] + +[[package]] +name = "criterion-plot" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1" +dependencies = [ + "cast", + "itertools", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" + +[[package]] +name = "crossterm" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8b9f2e4c67f833b660cdb0a3523065869fb35570177239812ed4c905aeff87b" +dependencies = [ + "bitflags", + "crossterm_winapi", + "document-features", + "parking_lot", + "rustix", + "winapi", +] + +[[package]] +name = "crossterm_winapi" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acdd7c62a3665c7f6830a51635d9ac9b23ed385797f70a83bb8bafe9c572ab2b" +dependencies = [ + "winapi", +] + +[[package]] +name = "crunchy" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" + +[[package]] +name = "csv" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52cd9d68cf7efc6ddfaaee42e7288d3a99d613d4b50f76ce9827ae0c6e14f938" +dependencies = [ + "csv-core", + "itoa", + "ryu", + "serde_core", +] + +[[package]] +name = "csv-core" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "704a3c26996a80471189265814dbc2c257598b96b8a7feae2d31ace646bb9782" +dependencies = [ + "memchr", +] + +[[package]] +name = "deranged" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ececcb659e7ba858fb4f10388c250a7252eb0a27373f1a72b8748afdd248e587" +dependencies = [ + "powerfmt", +] + +[[package]] +name = "difflib" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8" + +[[package]] +name = "document-features" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4b8a88685455ed29a21542a33abd9cb6510b6b129abadabdcef0f4c55bc8f61" +dependencies = [ + "litrs", +] + +[[package]] +name = "dyn-clone" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555" + +[[package]] +name = "either" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "errno" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "fastrand" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" + +[[package]] +name = "float-cmp" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b09cf3155332e944990140d967ff5eceb70df778b34f77d8075db46e4704e6d8" +dependencies = [ + "num-traits", +] + +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + +[[package]] +name = "getrandom" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "getrandom" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" +dependencies = [ + "cfg-if", + "libc", + "r-efi", + "wasip2", +] + +[[package]] +name = "globset" +version = "0.4.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52dfc19153a48bde0cbd630453615c8151bce3a5adfac7a0aebfbf0a1e1f57e3" +dependencies = [ + "aho-corasick", + "bstr", + "log", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "half" +version = "2.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ea2d84b969582b4b1864a92dc5d27cd2b77b622a8d79306834f1be5ba20d84b" +dependencies = [ + "cfg-if", + "crunchy", + "zerocopy", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +dependencies = [ + "ahash", +] + +[[package]] +name = "hashbrown" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" + +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hermit-abi" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc0fef456e4baa96da950455cd02c081ca953b141298e41db3fc7e36b1da849c" + +[[package]] +name = "ignore" +version = "0.4.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3d782a365a015e0f5c04902246139249abf769125006fbe7649e2ee88169b4a" +dependencies = [ + "crossbeam-deque", + "globset", + "log", + "memchr", + "regex-automata", + "same-file", + "walkdir", + "winapi-util", +] + +[[package]] +name = "indexmap" +version = "2.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7714e70437a7dc3ac8eb7e6f8df75fd8eb422675fc7678aff7364301092b1017" +dependencies = [ + "equivalent", + "hashbrown 0.16.1", +] + +[[package]] +name = "is-terminal" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3640c1c38b8e4e43584d8df18be5fc6b0aa314ce6ebf51b53313d4306cca8e46" +dependencies = [ + "hermit-abi", + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "is_terminal_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" + +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2" + +[[package]] +name = "js-sys" +version = "0.3.85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c942ebf8e95485ca0d52d97da7c5a2c387d0e7f0ba4c35e93bfcaee045955b3" +dependencies = [ + "once_cell", + "wasm-bindgen", +] + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "libc" +version = "0.2.180" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcc35a38544a891a5f7c865aca548a982ccb3b8650a5b06d0fd33a10283c56fc" + +[[package]] +name = "linux-raw-sys" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df1d3c3b53da64cf5760482273a98e575c651a67eec7f77df96b5b642de8f039" + +[[package]] +name = "litrs" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11d3d7f243d5c5a8b9bb5d6dd2b1602c0cb0b9db1621bafc7ed66e35ff9fe092" + +[[package]] +name = "lock_api" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" + +[[package]] +name = "memchr" +version = "2.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" + +[[package]] +name = "normalize-line-endings" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" + +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "once_cell" +version = "1.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" + +[[package]] +name = "once_cell_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" + +[[package]] +name = "oorandom" +version = "11.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6790f58c7ff633d8771f42965289203411a5e5c68388703c06e14f24770b41e" + +[[package]] +name = "parking_lot" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-link", +] + +[[package]] +name = "plotters" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aeb6f403d7a4911efb1e33402027fc44f29b5bf6def3effcc22d7bb75f2b747" +dependencies = [ + "num-traits", + "plotters-backend", + "plotters-svg", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "plotters-backend" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df42e13c12958a16b3f7f4386b9ab1f3e7933914ecea48da7139435263a4172a" + +[[package]] +name = "plotters-svg" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51bae2ac328883f7acdfea3d66a7c35751187f870bc81f94563733a154d7a670" +dependencies = [ + "plotters-backend", +] + +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + +[[package]] +name = "ppv-lite86" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "predicates" +version = "3.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5d19ee57562043d37e82899fade9a22ebab7be9cef5026b07fda9cdd4293573" +dependencies = [ + "anstyle", + "difflib", + "float-cmp", + "normalize-line-endings", + "predicates-core", + "regex", +] + +[[package]] +name = "predicates-core" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "727e462b119fe9c93fd0eb1429a5f7647394014cf3c04ab2c0350eeb09095ffa" + +[[package]] +name = "predicates-tree" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72dd2d6d381dfb73a193c7fca536518d7caee39fc8503f74e7dc0be0531b425c" +dependencies = [ + "predicates-core", + "termtree", +] + +[[package]] +name = "proc-macro-crate" +version = "3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "219cb19e96be00ab2e37d6e299658a0cfa83e52429179969b0f0121b4ac46983" +dependencies = [ + "toml_edit", +] + +[[package]] +name = "proc-macro2" +version = "1.0.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "ptr_meta" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0738ccf7ea06b608c10564b31debd4f5bc5e197fc8bfe088f68ae5ce81e7a4f1" +dependencies = [ + "ptr_meta_derive", +] + +[[package]] +name = "ptr_meta_derive" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "quote" +version = "1.0.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc74d9a594b72ae6656596548f56f667211f8a97b3d4c3d467150794690dc40a" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom 0.2.17", +] + +[[package]] +name = "rayon" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "368f01d005bf8fd9b1206fb6fa653e6c4a81ceb1466406b81792d87c5677a58f" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22e18b0f0062d30d4230b2e85ff77fdfe4326feb054b9783a3460d8435c8ab91" +dependencies = [ + "crossbeam-deque", + "crossbeam-utils", +] + +[[package]] +name = "redox_syscall" +version = "0.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" +dependencies = [ + "bitflags", +] + +[[package]] +name = "ref-cast" +version = "1.0.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f354300ae66f76f1c85c5f84693f0ce81d747e2c3f21a45fef496d89c960bf7d" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7186006dcb21920990093f30e3dea63b7d6e977bf1256be20c3563a5db070da" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.114", +] + +[[package]] +name = "regex" +version = "1.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "843bc0191f75f3e22651ae5f1e72939ab2f72a4bc30fa80a066bd66edefc24d4" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5276caf25ac86c8d810222b3dbb938e512c55c6831a10f3e6ed1c93b84041f1c" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58" + +[[package]] +name = "rend" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71fe3824f5629716b1589be05dacd749f6aa084c87e00e016714a8cdfccc997c" +dependencies = [ + "bytecheck", +] + +[[package]] +name = "rkyv" +version = "0.7.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2297bf9c81a3f0dc96bc9521370b88f054168c29826a75e89c55ff196e7ed6a1" +dependencies = [ + "bitvec", + "bytecheck", + "bytes", + "hashbrown 0.12.3", + "ptr_meta", + "rend", + "rkyv_derive", + "seahash", + "tinyvec", + "uuid", +] + +[[package]] +name = "rkyv_derive" +version = "0.7.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84d7b42d4b8d06048d3ac8db0eb31bcb942cbeb709f0b5f2b2ebde398d3038f5" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "roff" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88f8660c1ff60292143c98d08fc6e2f654d722db50410e3f3797d40baaf9d8f3" + +[[package]] +name = "rust_decimal" +version = "1.40.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61f703d19852dbf87cbc513643fa81428361eb6940f1ac14fd58155d295a3eb0" +dependencies = [ + "arrayvec", + "borsh", + "bytes", + "num-traits", + "rand", + "rkyv", + "serde", + "serde_json", +] + +[[package]] +name = "rustix" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "146c9e247ccc180c1f61615433868c99f3de3ae256a30a43b49f67c2d9171f34" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.61.2", +] + +[[package]] +name = "rustversion" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" + +[[package]] +name = "ryu" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a50f4cf475b65d88e057964e0e9bb1f0aa9bbb2036dc65c64596b42932536984" + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "schemars" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54e910108742c57a770f492731f99be216a52fadd361b06c8fb59d74ccc267d2" +dependencies = [ + "dyn-clone", + "ref-cast", + "serde", + "serde_json", +] + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "seahash" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" + +[[package]] +name = "serde" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.114", +] + +[[package]] +name = "serde_json" +version = "1.0.149" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "simdutf8" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" + +[[package]] +name = "sized" +version = "1.0.0" +dependencies = [ + "assert_cmd", + "byte-unit", + "clap", + "clap_complete", + "clap_mangen", + "colored", + "comfy-table", + "criterion", + "csv", + "ignore", + "predicates", + "rayon", + "serde", + "serde_json", + "strum", + "tempfile", + "time", +] + +[[package]] +name = "smallvec" +version = "1.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "strum" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" +dependencies = [ + "strum_macros", +] + +[[package]] +name = "strum_macros" +version = "0.25.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0" +dependencies = [ + "heck 0.4.1", + "proc-macro2", + "quote", + "rustversion", + "syn 2.0.114", +] + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.114" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4d107df263a3013ef9b1879b0df87d706ff80f65a86ea879bd9c31f9b307c2a" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + +[[package]] +name = "tempfile" +version = "3.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "655da9c7eb6305c55742045d5a8d2037996d61d8de95806335c7c86ce0f82e9c" +dependencies = [ + "fastrand", + "getrandom 0.3.4", + "once_cell", + "rustix", + "windows-sys 0.61.2", +] + +[[package]] +name = "termtree" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f50febec83f5ee1df3015341d8bd429f2d1cc62bcba7ea2076759d315084683" + +[[package]] +name = "time" +version = "0.3.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9e442fc33d7fdb45aa9bfeb312c095964abdf596f7567261062b2a7107aaabd" +dependencies = [ + "deranged", + "itoa", + "num-conv", + "powerfmt", + "serde_core", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b36ee98fd31ec7426d599183e8fe26932a8dc1fb76ddb6214d05493377d34ca" + +[[package]] +name = "time-macros" +version = "0.2.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71e552d1249bf61ac2a52db88179fd0673def1e1ad8243a00d9ec9ed71fee3dd" +dependencies = [ + "num-conv", + "time-core", +] + +[[package]] +name = "tinytemplate" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc" +dependencies = [ + "serde", + "serde_json", +] + +[[package]] +name = "tinyvec" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa5fdc3bce6191a1dbc8c02d5c8bffcf557bafa17c124c5264a458f1b0613fa" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "toml_datetime" +version = "0.7.5+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92e1cfed4a3038bc5a127e35a2d360f145e1f4b971b551a2ba5fd7aedf7e1347" +dependencies = [ + "serde_core", +] + +[[package]] +name = "toml_edit" +version = "0.23.10+spec-1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84c8b9f757e028cee9fa244aea147aab2a9ec09d5325a9b01e0a49730c2b5269" +dependencies = [ + "indexmap", + "toml_datetime", + "toml_parser", + "winnow", +] + +[[package]] +name = "toml_parser" +version = "1.0.6+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3198b4b0a8e11f09dd03e133c0280504d0801269e9afa46362ffde1cbeebf44" +dependencies = [ + "winnow", +] + +[[package]] +name = "unicode-ident" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5" + +[[package]] +name = "unicode-segmentation" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" + +[[package]] +name = "unicode-width" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254" + +[[package]] +name = "utf8-width" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1292c0d970b54115d14f2492fe0170adf21d68a1de108eebc51c1df4f346a091" + +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + +[[package]] +name = "uuid" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2e054861b4bd027cd373e18e8d8d8e6548085000e41290d95ce0c373a654b4a" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "wait-timeout" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ac3b126d3914f9849036f826e054cbabdc8519970b8998ddaf3b5bd3c65f11" +dependencies = [ + "libc", +] + +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "wasip2" +version = "1.0.2+wasi-0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9517f9239f02c069db75e65f174b3da828fe5f5b945c4dd26bd25d89c03ebcf5" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "wasm-bindgen" +version = "0.2.108" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64024a30ec1e37399cf85a7ffefebdb72205ca1c972291c51512360d90bd8566" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.108" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "008b239d9c740232e71bd39e8ef6429d27097518b6b30bdf9086833bd5b6d608" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.108" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5256bae2d58f54820e6490f9839c49780dff84c65aeab9e772f15d5f0e913a55" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn 2.0.114", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.108" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f01b580c9ac74c8d8f0c0e4afb04eeef2acf145458e52c03845ee9cd23e3d12" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "web-sys" +version = "0.3.85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "312e32e551d92129218ea9a2452120f4aabc03529ef03e4d0d82fb2780608598" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "winnow" +version = "0.7.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a5364e9d77fcdeeaa6062ced926ee3381faa2ee02d3eb83a5c27a8825540829" +dependencies = [ + "memchr", +] + +[[package]] +name = "wit-bindgen" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" + +[[package]] +name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] + +[[package]] +name = "zerocopy" +version = "0.8.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "668f5168d10b9ee831de31933dc111a459c97ec93225beb307aed970d1372dfd" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c7962b26b0a8685668b671ee4b54d007a67d4eaf05fda79ac0ecf41e32270f1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.114", +] + +[[package]] +name = "zmij" +version = "1.0.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfcd145825aace48cff44a8844de64bf75feec3080e0aa5cdbde72961ae51a65" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..b0d55c7 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,55 @@ +[package] +name = "sized" +version = "1.0.0" +edition = "2021" +description = "A modern, fast, and concurrent disk usage analyzer" +license = "GPL-3.0-only" +repository = "https://gitea.speelman.ca/gamertan/sized" +readme = "README.md" + +categories = ["command-line-utilities", "filesystem"] +keywords = ["du", "size", "disk", "usage", "parallel"] + +[package.metadata.deb] +maintainer = "Cole Speelman" +copyright = "2026, Cole Speelman" +license-file = ["LICENSE", "4"] +extended-description = """ +sized is a modern, fast, and concurrent disk usage analyzer. +Features include apparent vs disk usage, binary/decimal units, and gitignore support. +""" +section = "utils" +priority = "optional" +assets = [ + ["target/release/sized", "usr/bin/sized", "755"], + ["sized.1", "usr/share/man/man1/sized.1", "644"], + ["README.md", "usr/share/doc/sized/README.md", "644"], +] + + +[dependencies] +clap = { version = "4.4", features = ["derive"] } + +rayon = "1.8" +colored = "2.0" +comfy-table = "7.0" +byte-unit = "5.0" +strum = { version = "0.25", features = ["derive"] } +ignore = "0.4" +serde = { version = "1.0", features = ["derive"] } +serde_json = "1.0" +csv = "1.3" +time = { version = "0.3", features = ["macros", "formatting"] } +clap_complete = "4.4" +clap_mangen = "0.2.31" + +[dev-dependencies] +assert_cmd = "2.0" +predicates = "3.1" +tempfile = "3.10" +criterion = "0.5" + +[[bench]] +name = "benchmark" +harness = false + diff --git a/Formula/sized.rb b/Formula/sized.rb new file mode 100644 index 0000000..9ed088c --- /dev/null +++ b/Formula/sized.rb @@ -0,0 +1,23 @@ +class Sized < Formula + desc "A modern, fast, and concurrent disk usage analyzer" + homepage "https://gitea.speelman.ca/gamertan/sized" + url "https://gitea.speelman.ca/gamertan/sized/archive/v1.0.0.tar.gz" + sha256 "REPLACE_WITH_ACTUAL_SHA256" # Run `shasum -a 256 v0.2.0.tar.gz` after upload + license "GPL-3.0-only" + + depends_on "rust" => :build + + def install + system "cargo", "install", *std_cargo_args + + # Install man page + man1.install "sized.1" + + # Generate and install shell completions + generate_completions_from_executable(bin/"sized", "--completions") + end + + test do + system "#{bin}/sized", "--version" + end +end diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..f288702 --- /dev/null +++ b/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/MANUAL.md b/MANUAL.md new file mode 100644 index 0000000..44222a3 --- /dev/null +++ b/MANUAL.md @@ -0,0 +1,186 @@ +# Sized User Manual + +`sized` is a modern, fast, and concurrent disk usage analyzer for the command line, written in Rust. It is designed to provide quick insights into directory sizes with a focus on readability and flexibility. + +## Table of Contents +- [Installation](#installation) +- [Basic Usage](#basic-usage) +- [Filtering and sorting](#filtering-and-sorting) +- [Output Formats](#output-formats) +- [Advanced Features](#advanced-features) + - [Comparison Mode](#comparison-mode) + - [Gitignore Support](#gitignore-support) + - [Concurrency](#concurrency) + - [Exporting Data](#exporting-data) +- [Shell Completions](#shell-completions) + +## Installation + +### From Binaries (Recommended) +Download the latest pre-compiled binaries from the [Gitea Releases](https://gitea.speelman.ca/gamertan/sized/releases) page. + +### From Source +```bash +git clone https://gitea.speelman.ca/gamertan/sized.git +cd sized +make install # Installs binary and man page +``` + +## Basic Usage + +By default, `sized` analyzes the current directory recursively and displays a table of the immediate children. + +```bash +sized [path] +``` + +### Key Concepts +- **Disk Usage** (Default): The actual physical space consumed on disk (Blocks * 512 bytes). This is the "true" footprint and the metric `sized` prioritizes. +- **Apparent Size**: The logical size of the entry (file length). Available via the `-a` or `--apparent` flag. +- **Blocks**: The actual filesystem blocks allocated. + +### Path Display +- **Relative Path** (Default): `sized` shows paths relative to the current directory. +- **Full Path**: Use `-f` or `--path-full` to see absolute paths (e.g., `/Users/dev/project`). +- **Relative Toggle**: Use `--path-relative` to explicitly force relative paths (useful if overriding aliases). + +### Depth Control (`-d` / `--depth`) +By default, `sized` shows the immediate children of the target directory (depth 0). You can increase the recursion depth shown in the output. + +```bash +# Show current directory and its children's children +sized -d 1 +``` + +> [!NOTE] +> Regardless of the display depth, `sized` always calculates the *total* size of all subdirectories accurately by traversing the entire tree. + +## Filtering and Sorting + +### Sorting (`--sort`) +Sort the output table by a specific column. `sized` supports multi-column sorting. + +**Syntax**: `--sort ,[COLUMN:DIRECTION]` +- **Columns**: `name` (n), `size` (s, default disk usage), `type` (t), `apparent` (a), `blocks` (b) +- **Directions**: `asc` (a), `dsc` (d) + +**Examples**: +```bash +# Sort by size (largest first) - Default behavior +sized --sort size:dsc + +# Primary sort by Type, secondary sort by Size descending +sized --sort type:asc,size:dsc +``` + +### Minimum Size (`-m` / `--min-size`) +Hide entries smaller than a specific size to reduce noise. Supports standard units (KB, MB, GB, etc.). + +```bash +# Show only items larger than 100MB +sized -m 100MB +``` + +### Limiting Results (`-n` / `--number`) +Limit the number of rows displayed in each table. + +```bash +# Show only the top 10 largest items +sized --sort size:dsc -n 10 +``` + +## Output Formats (`--format`) + +`sized` supports multiple output formats for integration with other tools. + +### Table (Default) +The standard human-readable ASCII table with colors. +```bash +sized --format text +``` + +### CSV +Comma-Separated Values. +```bash +sized --format csv +``` + +### JSON +Computed metrics in NDJSON format. +```bash +sized --format json +``` + +## Advanced Features + +### Unit System (`--units`) +Switch between Binary (IEC) and Decimal (SI) units for the output. + +- **Binary** (Default): GiB, MiB, KiB (multiples of 1024). +- **Decimal**: GB, MB, KB (multiples of 1000). + +```bash +# Use decimal units (SI) +sized --units decimal +``` + +### Precision (`--precision`) +Specify the number of decimal places for formatted sizes. Defaults to `2`. + +```bash +# Higher precision for small files +sized --precision 4 +``` + +### Comparison Mode (`--compare`) +Compare the total physical size of a directory against its "filtered" size (files that would be included in a commit, respecting `.gitignore`). + +```bash +# Show both total and non-ignored metrics +sized -i -c +``` +This adds **"Filtered"** rows and headers to the output, allowing you to see how much space is consumed by ignored files (like `node_modules` or `target`). + +### Gitignore Support (`-i` / `--ignore`) +Respect `.ignore` and `.gitignore` files during traversal. This is highly recommended for developer workflows. + +```bash +# Exclude git-ignored files from calculations +sized -i +``` + +### Concurrency (`-j` / `--threads`) +`sized` uses parallel processing powered by `rayon` and `ignore`. By default, it uses a number of threads equal to your logical CPU cores. + +```bash +# Limit to 4 threads on a high-core system +sized -j 4 +``` + +### Exporting Data (`--save`) +Save the output directly to a file. If no filename is provided, `sized` generates a timestamped one (e.g., `sized_report_20260122_1430.txt`). + +```bash +# Save to an auto-generated file +sized --save + +# Save to a specific path +sized --save reports/my_audit.json --format json +``` + +## Shell Completions + +Generate shell completion scripts for Bash, Zsh, or Fish. + +```bash +# Generate for Zsh +sized --completions zsh > _sized +``` + +### Installation (Zsh example) +1. Generate the completion file: `sized --completions zsh > ~/.zfunc/_sized` +2. Add to your `.zshrc`: `fpath+=~/.zfunc; autoload -Uz compinit && compinit` + +## License + +This tool is licensed under the **GNU General Public License v3.0 (GPL-3.0)**. For more information, please refer to the `LICENSE` file in the project root. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..a5c8057 --- /dev/null +++ b/Makefile @@ -0,0 +1,25 @@ +PREFIX ?= /usr/local +BINDIR = $(PREFIX)/bin +MANDIR = $(PREFIX)/share/man/man1 + +.PHONY: all build install clean help + +all: build + +build: + cargo build --release + +install: build + install -d $(BINDIR) + install -m 755 target/release/sized $(BINDIR)/sized + install -d $(MANDIR) + install -m 644 sized.1 $(MANDIR)/sized.1 + +clean: + cargo clean + +help: + @echo "Usage:" + @echo " make build - Build the optimized binary" + @echo " make install - Install binary and man page (may require sudo)" + @echo " make clean - Remove build artifacts" diff --git a/README.md b/README.md new file mode 100644 index 0000000..b1abc6e --- /dev/null +++ b/README.md @@ -0,0 +1,159 @@ +# Sized + +A fast, concurrent, and feature-rich command-line tool for visualizing disk usage, written in Rust. + +## Features + +- **Physical by Default**: Prioritizes **Disk Usage** (actual blocks consumed) as the default metric, essential for accurately seeing how much storage is actually gone. +- **Fast & Concurrent**: Uses `rayon` to process directories in parallel, making it extremely fast on modern multi-core systems. +- **Rich Output**: Beautifully formatted tables with colors, distinguishing files and directories. +- **Apparent Size**: Toggle logical file length with `-a` or `--apparent`. +- **Unit Selection**: Switch between Binary (IEC) and Decimal (SI) unit systems via `--units`. +- **Precision control**: Configure decimal places using `--precision`. +- **Advanced Filtering**: Filter by minimum size (`-m 10MB`) to find large items quickly. +- **Sorting**: Flexible sorting by name, type, size (disk usage), or apparent size (`--sort`). +- **Gitignore Support**: Respects `.gitignore` and `.ignore` files to keep output clean (`-i`). +- **Export Options**: Export data to CSV or JSON for further analysis (`--format csv/json`). +- **Save to File**: Automatically save reports with timestamped filenames (`--save`). + +## Installation + +### 🚀 Direct Download (macOS & Linux) +Download the latest archive for your architecture from the [Releases](https://gitea.speelman.ca/gamertan/sized/releases) page. + +1. **Extract the archive**: + ```bash + tar -xzf sized-v1.0.0-Darwin-arm64.tar.gz + ``` + +2. **Install Binary & Man Page**: + ```bash + # Move binary to path + sudo mv sized /usr/local/bin/ + + # Install man page + sudo mkdir -p /usr/local/share/man/man1 + sudo cp sized.1 /usr/local/share/man/man1/ + ``` + +3. **macOS Security (Gatekeeper)**: + Since the binary isn't code-signed for the App Store, macOS may block it. To allow it: + ```bash + sudo xattr -d com.apple.quarantine /usr/local/bin/sized + ``` + *Alternatively, run `sized` once, let it fail, then go to **System Settings > Privacy & Security** and click **"Allow Anyway"**.* + +### 🍺 Homebrew (macOS & Linux) +If you have a homebrew tap: +```bash +brew install gamertan/tap/sized +``` + +### 📦 Debian / Ubuntu (.deb) +1. Download the `.deb` package from the [Releases](https://gitea.speelman.ca/gamertan/sized/releases) page. +2. Install using `dpkg`: + ```bash + sudo dpkg -i sized_1.0.0_amd64.deb + ``` + +### 🦀 From Source (Rust toolchain required) +```bash +git clone https://gitea.speelman.ca/gamertan/sized.git +cd sized +make install # Installs binary and man page +``` + +Alternatively, via Cargo: +```bash +cargo install --path . +``` + +## Documentation +- **[Manual](MANUAL.md)**: Detailed explanations of all flags and features. +- **[Man Page](sized.1)**: Standard unix man pages (installed via `make install`). + +## Usage + +### Basic Usage +Analyze the current directory: +```bash +sized +``` + +Analyze a specific path: +```bash +sized /path/to/directory +``` + +### Options + +| Flag | Description | Example | +|------|-------------|---------| +| `-a`, `--apparent` | Show apparent size (logical file length) | `sized -a` | +| `-d`, `--depth` | Recursion depth (0 = current dir only) | `sized -d 1` | +| `-m`, `--min-size` | Filter by minimum size | `sized -m 100MB` | +| `--sort` | Sort columns (name, type, size, apparent) | `sized --sort size:asc` | +| `--units` | Unit system (binary, decimal) | `sized --units decimal` | +| `--precision` | Decimal places for sizes | `sized --precision 3` | +| `-f`, `--path-full` | Force absolute paths in headers | `sized -f` | +| `-i`, `--ignore` | Respect .gitignore files | `sized -i` | +| `-j`, `--threads` | Set number of threads | `sized -j 4` | +| `--format` | Output format (text, csv, json) | `sized --format json` | +| `--save` | Save output to file | `sized --save` | +| `-c`, `--compare` | Compare total vs. non-ignored files | `sized -i -c` | + +### Examples + +**Find large directories (depth 1), respecting gitignore, and save to CSV:** +```bash +sized . -d 1 -i -m 50MB --format csv --save +``` + +### Generate Shell Completions + +**Bash:** +Add the following to your `.bashrc` or `.bash_profile`: +```bash +# Option 1: Source directly +source <(sized --completions bash) + +# Option 2: Save to file (safer startup time) +sized --completions bash > ~/.sized_completions.bash +echo "source ~/.sized_completions.bash" >> ~/.bashrc +``` + +**Zsh:** +```bash +# In your .zshrc +sized --completions zsh > /usr/local/share/zsh/site-functions/_sized +# OR +sized --completions zsh > ~/.zfunc/_sized +fpath+=~/.zfunc +autoload -Uz compinit && compinit +``` + +**Fish:** +```bash +sized --completions fish > ~/.config/fish/completions/sized.fish +``` + +## License + +This project is licensed under the **GNU General Public License v3.0 (GPL-3.0)**. + +### Why GPL-3.0? (The "Insulin" Philosophy) +We believe that core diagnostic tools like `sized` should remain a public good. Inspired by the philosophy behind open-access medicine like insulin, this license ensures that: +- The tool remains **free and open** for everyone to use. +- Any improvements or forks made by others **must also be shared** with the community. +- It prevents proprietary "vampire" versions from taking private credit for public efforts. + +For more details, see the [LICENSE](LICENSE) file. + +## Contributing + +Contributions are welcome but not required. + +By submitting a pull request, patch, or other contribution, you agree to the terms of the +[Contributor License Agreement](CLA.md). + +If you do not agree with the CLA, please do not submit contributions. diff --git a/SHIPMENT.md b/SHIPMENT.md new file mode 100644 index 0000000..c5ed164 --- /dev/null +++ b/SHIPMENT.md @@ -0,0 +1,59 @@ +# Project Release Process + +This document defines the process for versioning and distributing the `sized` project independently of the Git hosting provider (GitHub, GitLab, Gitea). + +## 1. Versioning and Tagging + +The project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +1. Synchronize the version in `Cargo.toml`. +2. Update `CHANGELOG.md` with the release notes. +3. Commit and create a git tag: + ```bash + git tag -a v1.0.0 -m "Release v1.0.0" + ``` + +## 2. Asset Generation + +The `scripts/release.sh` script is the authoritative way to generate release assets locally or in any CI environment. + +```bash +./scripts/release.sh +``` + +This script generates: +- **Optimized Binary**: The production-ready `sized` executable. +- **Documentation**: The `sized.1` man page. +- **Shell Completions**: Scripts for Bash, Zsh, and Fish. +- **System Installers**: A `.deb` package for Debian-based Linux distributions. + +All assets are gathered in the `dist/v/` directory. + +## 3. Distribution Channels + +### crates.io +To update the project on the central Rust registry: +```bash +cargo publish +``` + +### System Package Managers +For Homebrew, GitLab, or Gitea-based distribution: +1. Push the git tag to your SCM. +2. Run the release script to generate assets. +3. Attach the contents of the `dist/` folder to your SCM's "Release" or "Tag" entry. +4. Update downstream formulas (like `homebrew-tap`) with the new source URL and SHA256 of the generated tarball. + +## 4. Automation & Hooks + +To automate asset generation locally, you can use a git `post-checkout` or a wrapper script. Since gitea and gitlab use different CI formats, it is recommended to simply call `./scripts/release.sh` within your preferred CI runner (e.g., `gitlab-ci.yml` or `gitea-actions`). + +## 5. Manual Installation +For system-wide installation from source, use the `Makefile`: +```bash +make install +``` +Defaults to `PREFIX=/usr/local`. Overridable via `PREFIX=/your/path make install`. + +## 6. Contributions +The project accepts contributions under the terms of the [Contributor License Agreement](CLA.md). All pull requests must acknowledge agreement with these terms. diff --git a/benches/benchmark.rs b/benches/benchmark.rs new file mode 100644 index 0000000..607f6fc --- /dev/null +++ b/benches/benchmark.rs @@ -0,0 +1,34 @@ +use criterion::{black_box, criterion_group, criterion_main, Criterion}; +use sized::build_tree; +use std::fs::{self, File}; +use std::io::Write; +use tempfile::TempDir; // Ensure this is pub in lib.rs + +fn setup_test_dir() -> TempDir { + let temp_dir = TempDir::new().unwrap(); + let base_path = temp_dir.path(); + + // Create a moderately deep structure + for i in 0..10 { + let dir_path = base_path.join(format!("dir_{}", i)); + fs::create_dir(&dir_path).unwrap(); + for j in 0..10 { + let file_path = dir_path.join(format!("file_{}.txt", j)); + let mut file = File::create(file_path).unwrap(); + writeln!(file, "Some content for file {}-{}", i, j).unwrap(); + } + } + temp_dir +} + +fn criterion_benchmark(c: &mut Criterion) { + let temp_dir = setup_test_dir(); + let path = temp_dir.path(); + + c.bench_function("build_tree small", |b| { + b.iter(|| build_tree(black_box(path), black_box(false), black_box(false))) + }); +} + +criterion_group!(benches, criterion_benchmark); +criterion_main!(benches); diff --git a/scripts/release.sh b/scripts/release.sh new file mode 100755 index 0000000..8e2fe0d --- /dev/null +++ b/scripts/release.sh @@ -0,0 +1,53 @@ +#!/bin/bash +set -e + +VERSION=$(grep '^version =' Cargo.toml | cut -d '"' -f 2) +DIST_DIR="dist/v$VERSION" + +echo "Building release assets for sized v$VERSION..." + +# 1. Clean and Prepare +rm -rf "$DIST_DIR" +mkdir -p "$DIST_DIR" + +# 2. Build Release Binary +cargo build --release + +# 3. Generate Man Page +cargo run --release -- --generate-man-page "$DIST_DIR" + +# 4. Generate Completions +cargo run --release -- --completions bash > "$DIST_DIR/sized.bash" +cargo run --release -- --completions zsh > "$DIST_DIR/_sized" +cargo run --release -- --completions fish > "$DIST_DIR/sized.fish" + +# 5. Build Debian Package (if cargo-deb is installed) +if command -v cargo-deb &> /dev/null; then + echo "Building Debian package..." + # On macOS, we use --no-strip to avoid 'unrecognized option: --strip-unneeded' + # and --no-build because we already built the release binary. + cargo deb --no-build --no-strip + cp target/debian/*.deb "$DIST_DIR/" + echo "Note: .deb package contains the binary for $(uname -s)-$(uname -m)" +else + echo "Warning: cargo-deb not found. Skipping .deb packaging." +fi + +# 6. Build Alpine Package (Placeholder/Hook) +# Note: For real .apk building, one usually uses a docker container or abuild. +# This serves as a reminder for Alpine users. +if [ -f "APKBUILD" ] && command -v abuild &> /dev/null; then + echo "Building Alpine package..." + abuild -r +fi + +# 7. Create General Release Tarball +echo "Creating release tarball..." +tar -czf "dist/sized-v$VERSION-$(uname -s)-$(uname -m).tar.gz" -C "$DIST_DIR" . + +# 8. Copy Binary +cp target/release/sized "$DIST_DIR/" + +echo "Success! Assets are ready in $DIST_DIR" +ls -F "$DIST_DIR" +echo "Tarball: dist/sized-v$VERSION-$(uname -s)-$(uname -m).tar.gz" diff --git a/sized.1 b/sized.1 new file mode 100644 index 0000000..a080f9d --- /dev/null +++ b/sized.1 @@ -0,0 +1,81 @@ +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.TH sized 1 "sized 1.0.0" +.SH NAME +sized \- A modern, fast, and concurrent disk usage analyzer +.SH SYNOPSIS +\fBsized\fR [\fB\-v\fR|\fB\-\-version\fR] [\fB\-m\fR|\fB\-\-min\-size\fR] [\fB\-n\fR|\fB\-\-number\fR] [\fB\-\-sort\fR] [\fB\-a\fR|\fB\-\-apparent\fR] [\fB\-d\fR|\fB\-\-depth\fR] [\fB\-f\fR|\fB\-\-path\-full\fR] [\fB\-\-path\-relative\fR] [\fB\-j\fR|\fB\-\-threads\fR] [\fB\-\-completions\fR] [\fB\-i\fR|\fB\-\-ignore\fR] [\fB\-\-format\fR] [\fB\-\-save\fR] [\fB\-\-precision\fR] [\fB\-\-units\fR] [\fB\-c\fR|\fB\-\-compare\fR] [\fB\-h\fR|\fB\-\-help\fR] [\fIPATH\fR] +.SH DESCRIPTION +A modern, fast, and concurrent disk usage analyzer +.SH OPTIONS +.TP +\fB\-v\fR, \fB\-\-version\fR +Print version +.TP +\fB\-m\fR, \fB\-\-min\-size\fR \fI\fR +Minimum size filter (e.g. "10MB", "1gb") +.TP +\fB\-n\fR, \fB\-\-number\fR \fI\fR +Limit the number of results per table +.TP +\fB\-\-sort\fR \fI\fR +Sort by columns (e.g. "type:asc,size:dsc"). defaults to size:dsc. Columns: name, type, size (disk usage), apparent (logical), blocks +.TP +\fB\-a\fR, \fB\-\-apparent\fR +Show apparent size (logical file length) in addition to disk usage +.TP +\fB\-d\fR, \fB\-\-depth\fR \fI\fR [default: 0] +Depth to traverse (0 = only immediate children) +.TP +\fB\-f\fR, \fB\-\-path\-full\fR +Display full absolute paths +.TP +\fB\-\-path\-relative\fR +Display paths relative to current directory (default) +.TP +\fB\-j\fR, \fB\-\-threads\fR \fI\fR +Number of threads to use (defaults to available logical CPUs) +.TP +\fB\-\-completions\fR \fI\fR +Generate shell completions +.br + +.br +[\fIpossible values: \fRbash, elvish, fish, powershell, zsh] +.TP +\fB\-i\fR, \fB\-\-ignore\fR +Respect .gitignore and .ignore files +.TP +\fB\-\-format\fR \fI\fR [default: text] +Output format +.br + +.br +[\fIpossible values: \fRtext, csv, json] +.TP +\fB\-\-save\fR [\fI\fR] +Save output to file (optional filename, defaults to timestamped name) +.TP +\fB\-\-precision\fR \fI\fR [default: 2] +Precision for size output (decimal places) +.TP +\fB\-\-units\fR \fI\fR [default: binary] +Unit system to use +.br + +.br +[\fIpossible values: \fRbinary, decimal] +.TP +\fB\-c\fR, \fB\-\-compare\fR +Show comparison between total and non\-ignored files +.TP +\fB\-h\fR, \fB\-\-help\fR +Print help +.TP +[\fIPATH\fR] [default: .] +Directory to analyze +.SH VERSION +v1.0.0 + +.SH COPYRIGHT +sized is licensed under the GNU General Public License v3.0 (GPL-3.0). diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..37ce7d0 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,901 @@ +use byte_unit::{Byte, UnitType}; + +use clap::{CommandFactory, Parser, ValueEnum}; +use clap_complete::{generate, Shell}; +use colored::*; +use comfy_table::presets::UTF8_FULL; +use comfy_table::{Attribute, Cell, CellAlignment, Color, ContentArrangement, Table}; +use csv::WriterBuilder; +use ignore::WalkBuilder; +use rayon::prelude::*; +use serde::Serialize; +use std::cmp::Ordering; +use std::io::Write; +use std::os::unix::fs::MetadataExt; +use std::path::{Path, PathBuf}; +use std::str::FromStr; + +#[derive(Parser, Debug, Clone)] +#[command(author, version, about, long_about = None)] +#[command(disable_version_flag = true)] +pub struct Args { + /// Print version + #[arg(short = 'v', long, action = clap::ArgAction::Version)] + pub version: Option, + + /// Directory to analyze + #[arg(default_value = ".")] + pub path: PathBuf, + + /// Minimum size filter (e.g. "10MB", "1gb") + #[arg(short = 'm', long)] + pub min_size: Option, + + /// Limit the number of results per table + #[arg(short = 'n', long)] + pub number: Option, + + /// Sort by columns (e.g. "type:asc,size:dsc"). + /// defaults to size:dsc. + /// Columns: name, type, size (disk usage), apparent (logical), blocks. + #[arg(long)] + pub sort: Option, + + /// Show apparent size (logical file length) in addition to disk usage + #[arg(short = 'a', long)] + pub apparent: bool, + + /// Depth to traverse (0 = only immediate children) + #[arg(short, long, default_value = "0")] + pub depth: usize, + + /// Display full absolute paths + #[arg(short = 'f', long, conflicts_with = "path_relative")] + pub path_full: bool, + + /// Display paths relative to current directory (default) + #[arg(long)] + pub path_relative: bool, + + /// Number of threads to use (defaults to available logical CPUs) + #[arg(short = 'j', long = "threads")] + pub threads: Option, + + /// Generate shell completions + #[arg(long, value_enum)] + pub completions: Option, + + /// Respect .gitignore and .ignore files + #[arg(short = 'i', long)] + pub ignore: bool, + + /// Output format + #[arg(long, value_enum, default_value_t = OutputFormat::Text)] + pub format: OutputFormat, + + /// Save output to file (optional filename, defaults to timestamped name) + #[arg(long, num_args(0..=1), default_missing_value = "_AUTO_")] + pub save: Option, + + /// Precision for size output (decimal places) + #[arg(long, default_value = "2")] + pub precision: usize, + + /// Unit system to use + #[arg(long, value_enum, default_value_t = UnitSystem::Binary)] + pub units: UnitSystem, + + /// Show comparison between total and non-ignored files + #[arg(short = 'c', long)] + pub compare: bool, + + /// Generate man page to the specified output directory + #[arg(long, hide = true)] + pub generate_man_page: Option, +} + +#[derive(ValueEnum, Clone, Debug, PartialEq, Eq)] +pub enum OutputFormat { + Text, + Csv, + Json, +} + +#[derive(ValueEnum, Clone, Debug, PartialEq, Eq)] +pub enum UnitSystem { + Binary, + Decimal, +} + +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum SortColumn { + Name, + Type, + Disk, + Apparent, + Blocks, +} + +impl FromStr for SortColumn { + type Err = String; + fn from_str(s: &str) -> Result { + match s.to_lowercase().as_str() { + "name" | "n" => Ok(SortColumn::Name), + "type" | "t" => Ok(SortColumn::Type), + "size" | "s" | "disk" | "d" => Ok(SortColumn::Disk), + "apparent" | "a" => Ok(SortColumn::Apparent), + "blocks" | "b" => Ok(SortColumn::Blocks), + _ => Err(format!("Unknown column: {}", s)), + } + } +} + +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum SortDirection { + Asc, + Dsc, +} + +impl FromStr for SortDirection { + type Err = String; + fn from_str(s: &str) -> Result { + match s.to_lowercase().as_str() { + "asc" | "a" => Ok(SortDirection::Asc), + "dsc" | "d" | "desc" => Ok(SortDirection::Dsc), + _ => Err(format!("Unknown direction: {}", s)), + } + } +} + +#[derive(Clone, Serialize, Debug)] +pub struct Node { + pub path: PathBuf, + pub size_bytes: u64, + pub blocks: u64, + pub size_bytes_filtered: u64, + pub blocks_filtered: u64, + pub entry_type: EntryType, + pub accessible: bool, + #[serde(skip)] + pub children: Vec, +} + +#[derive(Clone, Serialize, Debug, PartialEq, Eq, PartialOrd, Ord)] +pub enum EntryType { + File, + Dir, +} + +impl std::fmt::Display for EntryType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + EntryType::File => write!(f, "File"), + EntryType::Dir => write!(f, "Dir"), + } + } +} + +pub fn run(args: Args, mut writer: &mut dyn Write) { + if let Some(shell) = args.completions { + let mut cmd = Args::command(); + let name = cmd.get_name().to_string(); + generate(shell, &mut cmd, name, &mut std::io::stdout()); + return; + } + + if let Some(out_dir) = args.generate_man_page { + let cmd = Args::command(); + let man = clap_mangen::Man::new(cmd); + let mut buffer: Vec = Default::default(); + man.render(&mut buffer).expect("Failed to render man page"); + + std::fs::create_dir_all(&out_dir).expect("Failed to create man page directory"); + let file_path = out_dir.join("sized.1"); + std::fs::write(&file_path, buffer).expect("Failed to write man page"); + println!("Man page generated at {}", file_path.display()); + return; + } + + if let Some(threads) = args.threads { + rayon::ThreadPoolBuilder::new() + .num_threads(threads) + .build_global() + .ok(); // Ignore error if initialized called multiple times (e.g. in tests) + } + + let target_path = args.path.clone(); + + if !target_path.exists() { + eprintln!("Error: Path '{}' does not exist.", target_path.display()); + std::process::exit(1); + } + + let min_bytes = if let Some(size_str) = &args.min_size { + match Byte::parse_str(size_str, true) { + Ok(byte) => byte.as_u64(), + Err(e) => { + eprintln!("Error parsing size '{}': {}", size_str, e); + std::process::exit(1); + } + } + } else { + 0 + }; + + let sort_criteria = parse_sort_arg(args.sort.as_deref().unwrap_or("size:dsc")); + + if args.format == OutputFormat::Csv { + if args.apparent { + writeln!(writer, "Path,Type,Apparent(Bytes),DiskUsage(Bytes),Blocks") + .expect("Failed to write CSV header"); + } else { + writeln!(writer, "Path,Type,DiskUsage(Bytes),Blocks") + .expect("Failed to write CSV header"); + } + } + + let root_node = build_tree(&target_path, args.ignore, args.compare); + + if root_node.size_bytes < min_bytes { + if args.format == OutputFormat::Text { + writeln!(writer, "Root directory is smaller than minimum size.").ok(); + } + return; + } + + process_node_recursive(&mut writer, &root_node, 0, &args, min_bytes, &sort_criteria); +} + +pub fn build_tree(path: &Path, ignore: bool, compare: bool) -> Node { + let metadata = path.symlink_metadata(); + + if let Ok(meta) = metadata { + // Treat symlinks as files (nodes) but do not recurse + if meta.is_file() || meta.is_symlink() { + return Node { + path: path.to_path_buf(), + size_bytes: meta.len(), + blocks: meta.blocks(), + size_bytes_filtered: meta.len(), // Single file is its own filtered size for now + blocks_filtered: meta.blocks(), + entry_type: EntryType::File, + accessible: true, + children: vec![], + }; + } + } + + // Check if we can read the directory (handle permissions) + if let Err(e) = std::fs::read_dir(path) { + if e.kind() == std::io::ErrorKind::PermissionDenied { + // Return an "empty" directory node marked as inaccessible + let meta = path.symlink_metadata().ok(); + let size = meta.as_ref().map(|m| m.len()).unwrap_or(0); + let blocks = meta.as_ref().map(|m| m.blocks()).unwrap_or(0); + return Node { + path: path.to_path_buf(), + size_bytes: size, + blocks, + size_bytes_filtered: size, + blocks_filtered: blocks, + entry_type: EntryType::Dir, + accessible: false, + children: vec![], + }; + } + } + + // Total walker (always everything if compare is true, else respects 'ignore' arg) + let total_ignore = if compare { false } else { ignore }; + let walker_total = WalkBuilder::new(path) + .standard_filters(false) + .hidden(false) + .git_ignore(total_ignore) + .ignore(total_ignore) + .max_depth(Some(1)) + .build(); + + let child_paths_total: Vec = walker_total + .into_iter() + .filter_map(|e| e.ok()) + .filter(|e| e.path() != path) + .map(|e| e.path().to_path_buf()) + .collect(); + + // Filtered set (only if compare is true) + let non_ignored_set: std::collections::HashSet = if compare { + let walker_filtered = WalkBuilder::new(path) + .standard_filters(false) + .hidden(false) + .git_ignore(true) + .ignore(true) + .max_depth(Some(1)) + .build(); + + walker_filtered + .into_iter() + .filter_map(|e| e.ok()) + .filter(|e| e.path() != path) + .map(|e| e.path().to_path_buf()) + .collect() + } else { + std::collections::HashSet::new() + }; + + let children: Vec = child_paths_total + .par_iter() + .map(|p| build_tree(p, ignore, compare)) + .collect(); + + let mut size_bytes = 0; + let mut blocks = 0; + let mut size_bytes_filtered = 0; + let mut blocks_filtered = 0; + + for child in &children { + size_bytes += child.size_bytes; + blocks += child.blocks; + + if compare { + if non_ignored_set.contains(&child.path) { + size_bytes_filtered += child.size_bytes_filtered; + blocks_filtered += child.blocks_filtered; + } + } else { + size_bytes_filtered += child.size_bytes_filtered; + blocks_filtered += child.blocks_filtered; + } + } + + let (self_size, self_blocks) = path + .symlink_metadata() + .map(|m| (m.len(), m.blocks())) + .unwrap_or((0, 0)); + + Node { + path: path.to_path_buf(), + size_bytes: size_bytes + self_size, + blocks: blocks + self_blocks, + size_bytes_filtered: size_bytes_filtered + self_size, // self is always part of self + blocks_filtered: blocks_filtered + self_blocks, + entry_type: EntryType::Dir, + accessible: true, + children, + } +} + +fn process_node_recursive( + writer: &mut dyn Write, + node: &Node, + current_depth: usize, + args: &Args, + min_bytes: u64, + sort_criteria: &[(SortColumn, SortDirection)], +) { + if node.children.is_empty() && node.entry_type == EntryType::Dir {} + + let mut display_children: Vec<&Node> = node + .children + .iter() + .filter(|c| c.size_bytes >= min_bytes) + .collect(); + + display_children.sort_by(|a, b| compare_nodes(a, b, sort_criteria)); + + if let Some(n) = args.number { + if n < display_children.len() { + display_children.truncate(n); + } + } + + let show_relative = !args.path_full; + let relative_path = if show_relative { + let cwd = std::env::current_dir().unwrap_or_default(); + node.path + .strip_prefix(&cwd) + .unwrap_or(&node.path) + .display() + .to_string() + } else { + node.path + .canonicalize() + .unwrap_or(node.path.clone()) + .display() + .to_string() + }; + + print_output( + writer, + &node, + &display_children, + args, + &relative_path, + current_depth, + ); + + if current_depth < args.depth { + for child in display_children { + if child.entry_type == EntryType::Dir { + process_node_recursive( + writer, + child, + current_depth + 1, + args, + min_bytes, + sort_criteria, + ); + } + } + } +} + +pub fn compare_nodes(a: &Node, b: &Node, criteria: &[(SortColumn, SortDirection)]) -> Ordering { + for (col, dir) in criteria { + let order = match col { + SortColumn::Name => a.path.file_name().cmp(&b.path.file_name()), + SortColumn::Type => a.entry_type.cmp(&b.entry_type), + SortColumn::Disk => a.blocks.cmp(&b.blocks), + SortColumn::Apparent => a.size_bytes.cmp(&b.size_bytes), + SortColumn::Blocks => a.blocks.cmp(&b.blocks), + }; + + if order != Ordering::Equal { + return match dir { + SortDirection::Asc => order, + SortDirection::Dsc => order.reverse(), + }; + } + } + Ordering::Equal +} + +pub fn parse_sort_arg(s: &str) -> Vec<(SortColumn, SortDirection)> { + s.split(',') + .filter_map(|part| { + let parts: Vec<&str> = part.split(':').collect(); + if parts.is_empty() { + return None; + } + + let col_str = parts[0]; + let col = SortColumn::from_str(col_str).ok()?; + + let dir = if parts.len() > 1 { + SortDirection::from_str(parts[1]).unwrap_or(SortDirection::Dsc) + } else { + match col { + SortColumn::Name | SortColumn::Type => SortDirection::Asc, + _ => SortDirection::Dsc, + } + }; + Some((col, dir)) + }) + .collect() +} + +fn print_output( + writer: &mut dyn Write, + parent_node: &Node, + children: &[&Node], + args: &Args, + relative_path: &str, + depth: usize, +) { + match args.format { + OutputFormat::Text => print_text(writer, parent_node, children, args, relative_path, depth), + OutputFormat::Csv => print_csv(writer, children, args), + OutputFormat::Json => print_json(writer, parent_node, children, args), + } +} + +fn print_text( + writer: &mut dyn Write, + parent_node: &Node, + children: &[&Node], + args: &Args, + relative_path: &str, + depth: usize, +) { + if depth > 0 { + writeln!(writer, "{}", "-".repeat(60).dimmed()).ok(); + } + writeln!(writer, "\n{}", relative_path.bold().blue()).ok(); + + let unit_type = match args.units { + UnitSystem::Binary => UnitType::Binary, + UnitSystem::Decimal => UnitType::Decimal, + }; + + if parent_node.accessible { + let total_usage = Byte::from_u64(parent_node.blocks * 512).get_appropriate_unit(unit_type); + + let mut summary = if args.apparent { + let total_apparent = + Byte::from_u64(parent_node.size_bytes).get_appropriate_unit(unit_type); + format!( + "Total Apparent: {} / Disk Usage: {} ({} blocks)", + format!( + "{:.precision$} {}", + total_apparent.get_value(), + total_apparent.get_unit(), + precision = args.precision + ) + .bold() + .green(), + format!( + "{:.precision$} {}", + total_usage.get_value(), + total_usage.get_unit(), + precision = args.precision + ) + .bold() + .green(), + parent_node.blocks + ) + } else { + format!( + "Disk Usage: {} ({} blocks)", + format!( + "{:.precision$} {}", + total_usage.get_value(), + total_usage.get_unit(), + precision = args.precision + ) + .bold() + .green(), + parent_node.blocks + ) + }; + + if args.compare { + let total_usage_filtered = + Byte::from_u64(parent_node.blocks_filtered * 512).get_appropriate_unit(unit_type); + + if args.apparent { + let total_apparent_filtered = + Byte::from_u64(parent_node.size_bytes_filtered).get_appropriate_unit(unit_type); + + summary.push_str(&format!( + "\nFiltered Apparent: {} / Filtered Disk Usage: {} ({} blocks)", + format!( + "{:.precision$} {}", + total_apparent_filtered.get_value(), + total_apparent_filtered.get_unit(), + precision = args.precision + ) + .bold() + .cyan(), + format!( + "{:.precision$} {}", + total_usage_filtered.get_value(), + total_usage_filtered.get_unit(), + precision = args.precision + ) + .bold() + .cyan(), + parent_node.blocks_filtered + )); + } else { + summary.push_str(&format!( + "\nFiltered Disk Usage: {} ({} blocks)", + format!( + "{:.precision$} {}", + total_usage_filtered.get_value(), + total_usage_filtered.get_unit(), + precision = args.precision + ) + .bold() + .cyan(), + parent_node.blocks_filtered + )); + } + } + + writeln!(writer, "{}", summary).ok(); + } else { + writeln!(writer, "Total size: {}", "Access Denied".bold().red()).ok(); + } + + if children.is_empty() { + if parent_node.accessible { + writeln!(writer, "(No children)").ok(); + } + return; + } + + let mut table = Table::new(); + table + .load_preset(UTF8_FULL) + .set_content_arrangement(ContentArrangement::Dynamic); + + let mut headers = vec![ + Cell::new("Name").add_attribute(Attribute::Bold), + Cell::new("Type").add_attribute(Attribute::Bold), + ]; + + if args.apparent { + headers.push( + Cell::new("Apparent") + .add_attribute(Attribute::Bold) + .set_alignment(CellAlignment::Right), + ); + } + + headers.push( + Cell::new("Disk Usage") + .add_attribute(Attribute::Bold) + .set_alignment(CellAlignment::Right), + ); + + if args.compare { + if args.apparent { + headers.push( + Cell::new("App. Filtered") + .add_attribute(Attribute::Bold) + .set_alignment(CellAlignment::Right), + ); + } + headers.push( + Cell::new("Disk Filtered") + .add_attribute(Attribute::Bold) + .set_alignment(CellAlignment::Right), + ); + } + + headers.push( + Cell::new("Blocks") + .add_attribute(Attribute::Bold) + .set_alignment(CellAlignment::Right), + ); + + table.set_header(headers); + + for child in children { + let name = child.path.file_name().unwrap_or_default().to_string_lossy(); + let color = if child.entry_type == EntryType::Dir { + Color::Blue + } else { + Color::Cyan + }; + + if child.accessible { + let mut row = vec![ + Cell::new(name).fg(color), + Cell::new(&child.entry_type).fg(Color::Yellow), + ]; + + if args.apparent { + let child_byte = Byte::from_u64(child.size_bytes).get_appropriate_unit(unit_type); + row.push( + Cell::new(format!( + "{:.precision$} {}", + child_byte.get_value(), + child_byte.get_unit(), + precision = args.precision + )) + .fg(Color::Green) + .set_alignment(CellAlignment::Right), + ); + } + + let disk_usage_byte = + Byte::from_u64(child.blocks * 512).get_appropriate_unit(unit_type); + row.push( + Cell::new(format!( + "{:.precision$} {}", + disk_usage_byte.get_value(), + disk_usage_byte.get_unit(), + precision = args.precision + )) + .fg(Color::Green) + .set_alignment(CellAlignment::Right), + ); + + if args.compare { + if args.apparent { + let child_byte_filtered = + Byte::from_u64(child.size_bytes_filtered).get_appropriate_unit(unit_type); + row.push( + Cell::new(format!( + "{:.precision$} {}", + child_byte_filtered.get_value(), + child_byte_filtered.get_unit(), + precision = args.precision + )) + .fg(Color::Cyan) + .set_alignment(CellAlignment::Right), + ); + } + + let disk_usage_byte_filtered = + Byte::from_u64(child.blocks_filtered * 512).get_appropriate_unit(unit_type); + row.push( + Cell::new(format!( + "{:.precision$} {}", + disk_usage_byte_filtered.get_value(), + disk_usage_byte_filtered.get_unit(), + precision = args.precision + )) + .fg(Color::Cyan) + .set_alignment(CellAlignment::Right), + ); + } + + row.push( + Cell::new(child.blocks) + .fg(Color::Green) + .set_alignment(CellAlignment::Right), + ); + + table.add_row(row); + } else { + let mut row = vec![ + Cell::new(name).fg(color), + Cell::new(&child.entry_type).fg(Color::Yellow), + Cell::new("N/A") + .fg(Color::Red) + .set_alignment(CellAlignment::Right), + Cell::new("Access Denied") + .fg(Color::Red) + .set_alignment(CellAlignment::Right), + ]; + + if args.compare { + row.push( + Cell::new("-") + .fg(Color::Red) + .set_alignment(CellAlignment::Right), + ); + row.push( + Cell::new("-") + .fg(Color::Red) + .set_alignment(CellAlignment::Right), + ); + } + + row.push( + Cell::new("-") + .fg(Color::Red) + .set_alignment(CellAlignment::Right), + ); + + table.add_row(row); + } + } + writeln!(writer, "{}", table).ok(); +} + +fn print_csv(writer: &mut dyn Write, children: &[&Node], args: &Args) { + let mut wtr = WriterBuilder::new().has_headers(false).from_writer(writer); + + for child in children { + let mut record = vec![ + child.path.to_string_lossy().to_string(), + child.entry_type.to_string(), + ]; + + if args.apparent { + record.push(child.size_bytes.to_string()); + } + + record.push((child.blocks * 512).to_string()); + record.push(child.blocks.to_string()); + + wtr.write_record(&record).ok(); + } + wtr.flush().ok(); +} + +fn print_json(writer: &mut dyn Write, parent_node: &Node, children: &[&Node], args: &Args) { + let entries_view: Vec = children + .iter() + .map(|c| { + let mut val = serde_json::json!({ + "path": &c.path, + "entry_type": c.entry_type.to_string(), + "accessible": c.accessible, + "disk_usage": c.blocks * 512, + "blocks": c.blocks, + }); + + if args.apparent { + val.as_object_mut() + .unwrap() + .insert("apparent_size".to_string(), serde_json::json!(c.size_bytes)); + } + + if args.compare { + val.as_object_mut().unwrap().insert( + "disk_usage_filtered".to_string(), + serde_json::json!(c.blocks_filtered * 512), + ); + val.as_object_mut().unwrap().insert( + "blocks_filtered".to_string(), + serde_json::json!(c.blocks_filtered), + ); + if args.apparent { + val.as_object_mut().unwrap().insert( + "apparent_size_filtered".to_string(), + serde_json::json!(c.size_bytes_filtered), + ); + } + } + + val + }) + .collect(); + + let mut report = serde_json::json!({ + "path": &parent_node.path, + "total_disk_usage": parent_node.blocks * 512, + "total_blocks": parent_node.blocks, + "entries": entries_view, + "accessible": parent_node.accessible, + }); + + if args.apparent { + report.as_object_mut().unwrap().insert( + "total_apparent".to_string(), + serde_json::json!(parent_node.size_bytes), + ); + } + + if args.compare { + report.as_object_mut().unwrap().insert( + "total_disk_usage_filtered".to_string(), + serde_json::json!(parent_node.blocks_filtered * 512), + ); + report.as_object_mut().unwrap().insert( + "total_blocks_filtered".to_string(), + serde_json::json!(parent_node.blocks_filtered), + ); + if args.apparent { + report.as_object_mut().unwrap().insert( + "total_apparent_filtered".to_string(), + serde_json::json!(parent_node.size_bytes_filtered), + ); + } + } + + serde_json::to_writer(&mut *writer, &report).ok(); + writer.write_all(b"\n").ok(); +} + +#[cfg(test)] +mod tests { + use super::*; + use std::fs::File; + use tempfile::TempDir; + + #[test] + fn test_parse_sort_arg() { + let criteria = parse_sort_arg("size:asc,name"); + assert_eq!(criteria.len(), 2); + assert_eq!(criteria[0], (SortColumn::Disk, SortDirection::Asc)); + assert_eq!(criteria[1], (SortColumn::Name, SortDirection::Asc)); // Default for Name is Asc + } + + #[test] + fn test_sort_defaults() { + let criteria = parse_sort_arg("size"); + assert_eq!(criteria[0], (SortColumn::Disk, SortDirection::Dsc)); // Default for Size is Dsc + } + + #[test] + fn test_build_tree() { + let temp_dir = TempDir::new().unwrap(); + let file_path = temp_dir.path().join("test_file.txt"); + File::create(&file_path) + .unwrap() + .write_all(b"Hello") + .unwrap(); + + let node = build_tree(temp_dir.path(), false, false); + + assert_eq!(node.entry_type, EntryType::Dir); + assert!(!node.children.is_empty()); + assert_eq!(node.children[0].path, file_path); + // Size should be at least 5 bytes + assert!(node.children[0].size_bytes >= 5); + } +} diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..4bd87fd --- /dev/null +++ b/src/main.rs @@ -0,0 +1,33 @@ +use clap::Parser; +use sized::{run, Args, OutputFormat}; +use std::io::Write; +use std::path::PathBuf; +use time::macros::format_description; +use time::OffsetDateTime; + +fn main() { + let args = Args::parse(); + + let mut writer: Box = if let Some(path_arg) = &args.save { + let output_path = if path_arg.to_string_lossy() == "_AUTO_" { + let format = format_description!("[year][month][day]-[hour][minute][second]"); + let timestamp = OffsetDateTime::now_utc().format(format).unwrap(); + let dir_name = args.path.file_name().unwrap_or_default().to_string_lossy(); + let ext = match args.format { + OutputFormat::Csv => "csv", + OutputFormat::Json => "json", + _ => "txt", + }; + PathBuf::from(format!("{}_{}.{}", timestamp, dir_name, ext)) + } else { + path_arg.clone() + }; + + let f = std::fs::File::create(&output_path).expect("Failed to create output file"); + Box::new(f) + } else { + Box::new(std::io::stdout()) + }; + + run(args, &mut writer); +} diff --git a/test_data/file1.txt b/test_data/file1.txt new file mode 100644 index 0000000..e56e15b --- /dev/null +++ b/test_data/file1.txt @@ -0,0 +1 @@ +12345 diff --git a/test_data/subdir/file2.txt b/test_data/subdir/file2.txt new file mode 100644 index 0000000..a32a434 --- /dev/null +++ b/test_data/subdir/file2.txt @@ -0,0 +1 @@ +1234567890 diff --git a/test_ops/.gitignore b/test_ops/.gitignore new file mode 100644 index 0000000..6a79f80 --- /dev/null +++ b/test_ops/.gitignore @@ -0,0 +1 @@ +ignored_file diff --git a/test_ops/a/large.file b/test_ops/a/large.file new file mode 100644 index 0000000..3995316 Binary files /dev/null and b/test_ops/a/large.file differ diff --git a/test_ops/b/medium.file b/test_ops/b/medium.file new file mode 100644 index 0000000..9e0f96a Binary files /dev/null and b/test_ops/b/medium.file differ diff --git a/test_ops/c/small.file b/test_ops/c/small.file new file mode 100644 index 0000000..9df6499 Binary files /dev/null and b/test_ops/c/small.file differ diff --git a/tests/cli.rs b/tests/cli.rs new file mode 100644 index 0000000..11d9c4c --- /dev/null +++ b/tests/cli.rs @@ -0,0 +1,47 @@ +use assert_cmd::prelude::*; +use predicates::prelude::*; +use std::fs::File; +use std::io::Write; +use std::process::Command; +use tempfile::TempDir; + +#[test] +fn test_basic_cli_run() { + let mut cmd = Command::new(env!("CARGO_BIN_EXE_sized")); + cmd.arg("--version") + .assert() + .success() + .stdout(predicate::str::contains("sized 1.0.0")); +} + +#[test] +fn test_run_on_directory() { + let temp_dir = TempDir::new().unwrap(); + let file_path = temp_dir.path().join("test_file.txt"); + File::create(&file_path) + .unwrap() + .write_all(b"Hello") + .unwrap(); + + let mut cmd = Command::new(env!("CARGO_BIN_EXE_sized")); + cmd.arg(temp_dir.path()) + .assert() + .success() + .stdout(predicate::str::contains("test_file.txt")); // Basic check +} + +#[test] +fn test_json_output() { + let temp_dir = TempDir::new().unwrap(); + let file_path = temp_dir.path().join("data.json"); + File::create(&file_path).unwrap().write_all(b"{}").unwrap(); + + let mut cmd = Command::new(env!("CARGO_BIN_EXE_sized")); + cmd.arg(temp_dir.path()) + .arg("--format") + .arg("json") + .assert() + .success() + .stdout(predicate::str::contains("\"entry_type\":\"File\"")) + .stdout(predicate::str::contains("\"path\":")); +}