Compare commits

..

No commits in common. "c06a7a527a4e7d8fcbe1dc84af89c4dc835bf631" and "b6c2d75bdb555542e8f6e0d7313602fbec77f209" have entirely different histories.

12 changed files with 86 additions and 260 deletions

View file

@ -6,7 +6,6 @@ image: "rust:latest"
variables: variables:
CARGO_HOME: $CI_PROJECT_DIR/.cargo CARGO_HOME: $CI_PROJECT_DIR/.cargo
PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/fif" PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/fif"
RUSTFLAGS: "-C debuginfo=0"
cache: cache:
paths: paths:
@ -38,7 +37,7 @@ stages:
script: script:
- cargo install cargo-sweep - cargo install cargo-sweep
- cargo sweep -i - cargo sweep -i
- git -C $CI_PROJECT_DIR/.cargo/registry/index/github.com-1ecc6299db9ec823/ gc --aggressive || true - git -C $CI_PROJECT_DIR/.cargo/registry/index/github.com-1ecc6299db9ec823/ gc || true
# this builds a "base" version of fif with default features enabled. this is done separately from the main build step # this builds a "base" version of fif with default features enabled. this is done separately from the main build step
# for the purposes of caching - by building once *before* executing the parallel cargo-build step, we ensure that # for the purposes of caching - by building once *before* executing the parallel cargo-build step, we ensure that
@ -105,7 +104,7 @@ build-base-stable:
build-base-msrv: build-base-msrv:
extends: build-base-stable extends: build-base-stable
image: "rust:1.54.0" image: "rust:1.48.0"
cache: cache:
key: msrv key: msrv
paths: paths:
@ -131,7 +130,7 @@ build-stable:
build-msrv: build-msrv:
extends: build-stable extends: build-stable
needs: ["build-base-msrv"] needs: ["build-base-msrv"]
image: "rust:1.54.0" image: "rust:1.48.0"
cache: cache:
key: msrv key: msrv
paths: paths:
@ -156,7 +155,7 @@ test-stable:
test-msrv: test-msrv:
extends: test-stable extends: test-stable
image: "rust:1.54.0" image: "rust:1.48.0"
needs: ["build-msrv"] needs: ["build-msrv"]
cache: cache:
key: msrv key: msrv

View file

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="MarkdownSettings">
<enabledExtensions>
<entry key="MermaidLanguageExtension" value="false" />
<entry key="PlantUMLLanguageExtension" value="false" />
</enabledExtensions>
</component>
</project>

View file

@ -4,16 +4,13 @@ Dates are given in YYYY-MM-DD format - for example, the 15th of October 2021 is
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to 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). [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## v0.5.0 - 2022-01-01 ## Unreleased
### Changed ### Changed
- The Minimum Supported Rust Version (MSRV) is now **1.54.0**.
- Updated [`new_mime_guess`] to 4.0.0 - Updated [`new_mime_guess`] to 4.0.0
- `--version` output now handles missing Git commit hashes, and specifies the target operating system
### Fixed ### Fixed
- Disabled [`smartstring`] test on unsupported architectures - Disabled [`smartstring`] test on unsupported architectures
### Other ### Other
- Use [`parking_lot`]'s `RwLock` instead of the built-in one for a slight performance increase - Use [`parking_lot`]'s `RwLock` instead of the built-in one for a slight performance increase
- Added more command line argument tests
## v0.4.0 - 2021-10-14 ## v0.4.0 - 2021-10-14
### Added ### Added

197
Cargo.lock generated
View file

@ -8,20 +8,6 @@ version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
[[package]]
name = "assert_cmd"
version = "2.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e996dc7940838b7ef1096b882e29ec30a3149a3a443cdc8dba19ed382eca1fe2"
dependencies = [
"bstr",
"doc-comment",
"predicates",
"predicates-core",
"predicates-tree",
"wait-timeout",
]
[[package]] [[package]]
name = "atty" name = "atty"
version = "0.2.14" version = "0.2.14"
@ -41,20 +27,9 @@ checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
[[package]] [[package]]
name = "bitflags" name = "bitflags"
version = "1.3.2" version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
[[package]]
name = "bstr"
version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223"
dependencies = [
"lazy_static",
"memchr",
"regex-automata",
]
[[package]] [[package]]
name = "byteorder" name = "byteorder"
@ -80,9 +55,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]] [[package]]
name = "clap" name = "clap"
version = "3.0.0" version = "3.0.0-beta.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d17bf219fcd37199b9a29e00ba65dfb8cd5b2688b7297ec14ff829c40ac50ca9" checksum = "4bd1061998a501ee7d4b6d449020df3266ca3124b941ec56cf2005c3779ca142"
dependencies = [ dependencies = [
"atty", "atty",
"bitflags", "bitflags",
@ -93,14 +68,15 @@ dependencies = [
"termcolor", "termcolor",
"terminal_size", "terminal_size",
"textwrap", "textwrap",
"unicase", "unicode-width",
"vec_map",
] ]
[[package]] [[package]]
name = "clap_derive" name = "clap_derive"
version = "3.0.0" version = "3.0.0-beta.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e1b9752c030a14235a0bd5ef3ad60a1dcac8468c30921327fc8af36b20c790b9" checksum = "370f715b81112975b1b69db93e0b56ea4cd4e5002ac43b2da8474106a54096a1"
dependencies = [ dependencies = [
"heck", "heck",
"proc-macro-error", "proc-macro-error",
@ -153,12 +129,6 @@ dependencies = [
"lazy_static", "lazy_static",
] ]
[[package]]
name = "difflib"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8"
[[package]] [[package]]
name = "dirs-next" name = "dirs-next"
version = "2.0.0" version = "2.0.0"
@ -180,12 +150,6 @@ dependencies = [
"winapi", "winapi",
] ]
[[package]]
name = "doc-comment"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10"
[[package]] [[package]]
name = "either" name = "either"
version = "1.6.1" version = "1.6.1"
@ -211,11 +175,11 @@ checksum = "de853764b47027c2e862a995c34978ffa63c1501f2e15f987ba11bd4f9bba193"
[[package]] [[package]]
name = "fif" name = "fif"
version = "0.5.0" version = "0.4.0"
dependencies = [ dependencies = [
"assert_cmd",
"cfg-if", "cfg-if",
"clap", "clap",
"clap_derive",
"env_logger", "env_logger",
"exitcode", "exitcode",
"infer", "infer",
@ -229,7 +193,6 @@ dependencies = [
"parking_lot", "parking_lot",
"rand", "rand",
"rayon", "rayon",
"regex",
"serde", "serde",
"serde_json", "serde_json",
"smartstring", "smartstring",
@ -310,18 +273,18 @@ dependencies = [
[[package]] [[package]]
name = "itertools" name = "itertools"
version = "0.10.3" version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3" checksum = "69ddb889f9d0d08a67338271fa9b62996bc788c7796a5c18cf057420aaed5eaf"
dependencies = [ dependencies = [
"either", "either",
] ]
[[package]] [[package]]
name = "itoa" name = "itoa"
version = "1.0.1" version = "0.4.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4"
[[package]] [[package]]
name = "lazy_static" name = "lazy_static"
@ -344,9 +307,9 @@ dependencies = [
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.112" version = "0.2.108"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b03d17f364a3a042d5e5d46b053bbbf82c92c9430c592dd4c064dc6ee997125" checksum = "8521a1b57e76b1ec69af7599e75e38e7b7fad6610f037db8c79b127201b5d119"
[[package]] [[package]]
name = "lock_api" name = "lock_api"
@ -380,9 +343,9 @@ checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a"
[[package]] [[package]]
name = "memoffset" name = "memoffset"
version = "0.6.5" version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9"
dependencies = [ dependencies = [
"autocfg", "autocfg",
] ]
@ -418,9 +381,9 @@ dependencies = [
[[package]] [[package]]
name = "num_cpus" name = "num_cpus"
version = "1.13.1" version = "1.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3"
dependencies = [ dependencies = [
"hermit-abi", "hermit-abi",
"libc", "libc",
@ -428,18 +391,15 @@ dependencies = [
[[package]] [[package]]
name = "once_cell" name = "once_cell"
version = "1.9.0" version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5" checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56"
[[package]] [[package]]
name = "os_str_bytes" name = "os_str_bytes"
version = "6.0.0" version = "2.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64" checksum = "afb2e1c3ee07430c2cf76151675e583e0f19985fa6efae47d6848a3e2c824f85"
dependencies = [
"memchr",
]
[[package]] [[package]]
name = "parking_lot" name = "parking_lot"
@ -468,9 +428,9 @@ dependencies = [
[[package]] [[package]]
name = "phf" name = "phf"
version = "0.10.1" version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fabbf1ead8a5bcbc20f5f8b939ee3f5b0f6f281b6ad3468b84656b658b455259" checksum = "b9fc3db1018c4b59d7d582a739436478b6035138b6aecbce989fc91c3e98409f"
dependencies = [ dependencies = [
"phf_shared", "phf_shared",
] ]
@ -507,36 +467,9 @@ dependencies = [
[[package]] [[package]]
name = "ppv-lite86" name = "ppv-lite86"
version = "0.2.16" version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" checksum = "ed0cfbc8191465bed66e1718596ee0b0b35d5ee1f41c5df2189d0fe8bde535ba"
[[package]]
name = "predicates"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95e5a7689e456ab905c22c2b48225bb921aba7c8dfa58440d68ba13f6222a715"
dependencies = [
"difflib",
"itertools",
"predicates-core",
]
[[package]]
name = "predicates-core"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57e35a3326b75e49aa85f5dc6ec15b41108cf5aee58eabb1f274dd18b73c2451"
[[package]]
name = "predicates-tree"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "338c7be2905b732ae3984a2f40032b5e94fd8f52505b186c7d4d68d193445df7"
dependencies = [
"predicates-core",
"termtree",
]
[[package]] [[package]]
name = "proc-macro-error" name = "proc-macro-error"
@ -564,18 +497,18 @@ dependencies = [
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.36" version = "1.0.32"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029" checksum = "ba508cc11742c0dc5c1659771673afbab7a0efab23aa17e854cbab0837ed0b43"
dependencies = [ dependencies = [
"unicode-xid", "unicode-xid",
] ]
[[package]] [[package]]
name = "quote" name = "quote"
version = "1.0.14" version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "47aa80447ce4daf1717500037052af176af5d38cc3e571d9ec1c7353fc10c87d" checksum = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
] ]
@ -664,27 +597,6 @@ dependencies = [
"redox_syscall", "redox_syscall",
] ]
[[package]]
name = "regex"
version = "1.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461"
dependencies = [
"regex-syntax",
]
[[package]]
name = "regex-automata"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"
[[package]]
name = "regex-syntax"
version = "0.6.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b"
[[package]] [[package]]
name = "remove_dir_all" name = "remove_dir_all"
version = "0.5.3" version = "0.5.3"
@ -696,9 +608,9 @@ dependencies = [
[[package]] [[package]]
name = "ryu" name = "ryu"
version = "1.0.9" version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e"
[[package]] [[package]]
name = "same-file" name = "same-file"
@ -717,18 +629,18 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.132" version = "1.0.130"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b9875c23cf305cd1fd7eb77234cbb705f21ea6a72c637a5c6db5fe4b8e7f008" checksum = "f12d06de37cf59146fbdecab66aa99f9fe4f78722e3607577a5375d66bd0c913"
dependencies = [ dependencies = [
"serde_derive", "serde_derive",
] ]
[[package]] [[package]]
name = "serde_derive" name = "serde_derive"
version = "1.0.132" version = "1.0.130"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ecc0db5cb2556c0e558887d9bbdcf6ac4471e83ff66cf696e5419024d1606276" checksum = "d7bc1a1ab1961464eae040d96713baa5a724a8152c1222492465b54322ec508b"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -737,9 +649,9 @@ dependencies = [
[[package]] [[package]]
name = "serde_json" name = "serde_json"
version = "1.0.73" version = "1.0.71"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bcbd0344bc6533bc7ec56df11d42fb70f1b912351c0825ccb7211b59d8af7cf5" checksum = "063bf466a64011ac24040a49009724ee60a57da1b437617ceb32e53ad61bfb19"
dependencies = [ dependencies = [
"itoa", "itoa",
"ryu", "ryu",
@ -785,9 +697,9 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]] [[package]]
name = "syn" name = "syn"
version = "1.0.84" version = "1.0.81"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ecb2e6da8ee5eb9a61068762a32fa9619cc591ceb055b3687f4cd4051ec2e06b" checksum = "f2afee18b8beb5a596ecb4a2dce128c719b4ba399d34126b9e4396e3f9860966"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -827,17 +739,11 @@ dependencies = [
"winapi", "winapi",
] ]
[[package]]
name = "termtree"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13a4ec180a2de59b57434704ccfad967f789b12737738798fa08798cd5824c16"
[[package]] [[package]]
name = "textwrap" name = "textwrap"
version = "0.14.2" version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0066c8d12af8b5acd21e00547c3797fde4e8677254a7ee429176ccebbe93dd80" checksum = "203008d98caf094106cfaba70acfed15e18ed3ddb7d94e49baec153a2b462789"
dependencies = [ dependencies = [
"terminal_size", "terminal_size",
"unicode-width", "unicode-width",
@ -903,19 +809,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7"
[[package]] [[package]]
name = "version_check" name = "vec_map"
version = "0.9.4" version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
[[package]] [[package]]
name = "wait-timeout" name = "version_check"
version = "0.2.0" version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f200f5b12eb75f8c1ed65abd4b2db8a6e1b138a20de009dacee265a2498f3f6" checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe"
dependencies = [
"libc",
]
[[package]] [[package]]
name = "walkdir" name = "walkdir"

View file

@ -4,11 +4,11 @@
[package] [package]
name = "fif" name = "fif"
description = "A command-line tool for detecting and optionally correcting files with incorrect extensions." description = "A command-line tool for detecting and optionally correcting files with incorrect extensions."
version = "0.5.0" version = "0.4.0"
authors = ["Lynnesbian <lynne@bune.city>"] authors = ["Lynnesbian <lynne@bune.city>"]
edition = "2018" edition = "2018"
license = "GPL-3.0-or-later" license = "GPL-3.0-or-later"
rust-version = "1.54.0" # clap 3 requires >=1.54.0 rust-version = "1.48.0" # this can actually go as low as 1.41.0 after removing cached, but i'll leave it 1.43.0
repository = "https://gitlab.com/Lynnesbian/fif" repository = "https://gitlab.com/Lynnesbian/fif"
readme = "README.md" readme = "README.md"
keywords = ["mime", "mimetype", "utilities", "tools"] keywords = ["mime", "mimetype", "utilities", "tools"]
@ -62,9 +62,13 @@ smartstring = ">= 0.2.4"
[dependencies.clap] [dependencies.clap]
# beta.4 requires rust >= 1.54.0 (and beta.3 was yanked) # beta.4 requires rust >= 1.54.0 (and beta.3 was yanked)
version = "3.0.0" version = "=3.0.0-beta.2"
default-features = false default-features = false
features = ["wrap_help", "color", "derive", "std", "unicode"] features = ["wrap_help", "color", "derive", "std"]
[dependencies.clap_derive]
# without this, clap beta.2 will install clap_derive beta.4 :c
version = "=3.0.0-beta.2"
[dependencies.env_logger] [dependencies.env_logger]
version = "0.9.0" version = "0.9.0"
@ -74,8 +78,6 @@ features = ["termcolor", "atty"]
[dev-dependencies] [dev-dependencies]
tempfile = "3.2.0" tempfile = "3.2.0"
rand = "0.8.3" rand = "0.8.3"
assert_cmd = "2.0.2"
regex = { version = "1.5.4", default-features = false, features = ["std"] }
[profile.release] [profile.release]
lto = "thin" lto = "thin"
@ -88,4 +90,4 @@ opt-level = 3
opt-level = 3 opt-level = 3
[package.metadata] [package.metadata]
msrv = "1.54.0" msrv = "1.48.0"

View file

@ -7,7 +7,7 @@
[![Version](https://img.shields.io/crates/v/fif.svg?logo=rust&style=flat-square) [![Version](https://img.shields.io/crates/v/fif.svg?logo=rust&style=flat-square)
](https://crates.io/crates/fif) ](https://crates.io/crates/fif)
[![Minimum Supported Rust Version](https://img.shields.io/badge/msrv-1.54.0-orange?logo=rust&style=flat-square) [![Minimum Supported Rust Version](https://img.shields.io/badge/msrv-1.48.0-orange?logo=rust&style=flat-square)
](https://gitlab.com/Lynnesbian/fif/-/blob/master/README.md#version-policy) ](https://gitlab.com/Lynnesbian/fif/-/blob/master/README.md#version-policy)
[![License](https://img.shields.io/crates/l/fif.svg?style=flat-square) [![License](https://img.shields.io/crates/l/fif.svg?style=flat-square)
](https://gitlab.com/Lynnesbian/fif/-/blob/master/LICENSE) ](https://gitlab.com/Lynnesbian/fif/-/blob/master/LICENSE)

View file

@ -3,4 +3,4 @@
# avoid-breaking-exported-api = false # only available on nightly for now # avoid-breaking-exported-api = false # only available on nightly for now
cognitive-complexity-threshold = 15 cognitive-complexity-threshold = 15
msrv = "1.54.0" msrv = "1.48.0"

View file

@ -321,7 +321,7 @@ pub fn mime_extension_lookup(essence: String) -> Option<Vec<String>> {
exts = mime_guess::get_mime_extensions_str(&essence.replace("/x-", "/")); exts = mime_guess::get_mime_extensions_str(&essence.replace("/x-", "/"));
} else { } else {
// replace e.g. "video/mp2t" with "video/x-mp2t" // replace e.g. "video/mp2t" with "video/x-mp2t"
exts = mime_guess::get_mime_extensions_str(&essence.replace('/', "/x-")); exts = mime_guess::get_mime_extensions_str(&essence.replace("/", "/x-"));
} }
} }

View file

@ -16,7 +16,7 @@ use std::io::{stdin, stdout, BufWriter, Write};
use std::process::exit; use std::process::exit;
use cfg_if::cfg_if; use cfg_if::cfg_if;
use clap::Parser; use clap::Clap;
use fif::files::{scan_directory, scan_from_walkdir}; use fif::files::{scan_directory, scan_from_walkdir};
use fif::formats::{self, Format}; use fif::formats::{self, Format};
use fif::parameters::{self, OutputFormat, Prompt}; use fif::parameters::{self, OutputFormat, Prompt};

View file

@ -7,7 +7,7 @@ use std::collections::BTreeSet;
use std::path::PathBuf; use std::path::PathBuf;
use cfg_if::cfg_if; use cfg_if::cfg_if;
use clap::{Parser, ArgEnum}; use clap::{AppSettings, Clap};
use crate::utils::{CLAP_LONG_VERSION, CLAP_VERSION}; use crate::utils::{CLAP_LONG_VERSION, CLAP_VERSION};
use crate::String as StringType; use crate::String as StringType;
@ -22,7 +22,7 @@ cfg_if! {
} }
} }
#[derive(ArgEnum, PartialEq, Debug, Copy, Clone)] #[derive(Clap, PartialEq, Debug, Copy, Clone)]
/// The format to use when running fif without the `--fix` flag. Specified at runtime with the `-o`/`--output-format` /// The format to use when running fif without the `--fix` flag. Specified at runtime with the `-o`/`--output-format`
/// flag. /// flag.
pub enum OutputFormat { pub enum OutputFormat {
@ -39,7 +39,7 @@ pub enum OutputFormat {
Json, Json,
} }
#[derive(ArgEnum, PartialEq, Debug, Copy, Clone)] #[derive(Clap, PartialEq, Debug, Copy, Clone)]
/// Specifies under what conditions the user should be prompted when running fif in `--fix` mode. Defaults to `Error`. /// Specifies under what conditions the user should be prompted when running fif in `--fix` mode. Defaults to `Error`.
/// Specified at runtime with the `-p`/`--prompt` flag. /// Specified at runtime with the `-p`/`--prompt` flag.
pub enum Prompt { pub enum Prompt {
@ -51,7 +51,7 @@ pub enum Prompt {
Always, Always,
} }
#[derive(Parser, Debug)] #[derive(Clap, Debug)]
#[allow(clippy::struct_excessive_bools)] #[allow(clippy::struct_excessive_bools)]
#[clap( #[clap(
version = CLAP_VERSION.as_str(), version = CLAP_VERSION.as_str(),
@ -63,6 +63,7 @@ pub enum Prompt {
This program is free software: you can redistribute it and/or modify \ 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 \ 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.", of the License, or (at your option) any later version.",
setting(AppSettings::ColoredHelp),
max_term_width = 120 max_term_width = 120
)] )]
/// [`Clap`]-derived struct used to parse command line arguments. /// [`Clap`]-derived struct used to parse command line arguments.
@ -87,7 +88,7 @@ pub struct Parameters {
/// Only examine files with these extensions. /// Only examine files with these extensions.
/// Multiple extensions can be specified by either using the flag multiple times (`-e jpg -e png -e gif`), or by /// Multiple extensions can be specified by either using the flag multiple times (`-e jpg -e png -e gif`), or by
/// separating them with commas (`-e jpg,png,gif`). /// separating them with commas (`-e jpg,png,gif`).
#[clap(short, long, use_delimiter = true, require_delimiter = true, value_name = "ext", takes_value = true, validator = validate_exts)] #[clap(short, long, use_delimiter = true, require_delimiter = true, value_name = "ext", validator = lowercase_exts)]
pub exts: Option<Vec<StringType>>, pub exts: Option<Vec<StringType>>,
/// Use these preset lists of extensions as the search filter (comma-separated list). /// Use these preset lists of extensions as the search filter (comma-separated list).
@ -105,8 +106,7 @@ pub struct Parameters {
/// Don't scan files with these extensions. /// Don't scan files with these extensions.
/// This option takes precedence over extensions specified with `-e` or `-E`. /// This option takes precedence over extensions specified with `-e` or `-E`.
#[clap(short = 'x', long, use_delimiter = true, require_delimiter = true, value_name = "ext", validator = #[clap(short = 'x', long, use_delimiter = true, require_delimiter = true, value_name = "ext", validator = lowercase_exts)]
validate_exts)]
pub exclude: Option<Vec<StringType>>, pub exclude: Option<Vec<StringType>>,
/// Exclude files using a preset list of extensions. /// Exclude files using a preset list of extensions.
@ -177,15 +177,9 @@ pub struct Parameters {
pub jobs: usize, pub jobs: usize,
} }
/// Validation function for argument parsing that ensures passed-in extensions are lowercase, and that the user /// Validation function for argument parsing that ensures passed-in extensions are lowercase.
/// didn't supply an empty list. fn lowercase_exts(exts: &str) -> Result<(), String> {
fn validate_exts(exts: &str) -> Result<(), String> {
// TODO: i would much rather accept uppercase exts and convert them to lowercase than just rejecting lowercase exts... // TODO: i would much rather accept uppercase exts and convert them to lowercase than just rejecting lowercase exts...
if exts.is_empty() {
return Err(String::from("Cannot specify empty extensions"));
}
if exts.to_lowercase() != exts { if exts.to_lowercase() != exts {
return Err(String::from("Supplied extensions must be lowercase")); return Err(String::from("Supplied extensions must be lowercase"));
} }
@ -296,7 +290,7 @@ impl Parameters {
} }
/// Sets of extensions for use with [Parameter](crate::parameters::Parameters)'s `-E` flag. /// Sets of extensions for use with [Parameter](crate::parameters::Parameters)'s `-E` flag.
#[derive(ArgEnum, PartialEq, Debug, Copy, Clone)] #[derive(Clap, PartialEq, Debug, Copy, Clone)]
pub enum ExtensionSet { pub enum ExtensionSet {
/// Extensions used for image file formats, such as `png`, `jpeg`, `webp`, etc. /// Extensions used for image file formats, such as `png`, `jpeg`, `webp`, etc.
Images, Images,

View file

@ -6,7 +6,7 @@ use std::collections::{BTreeMap, HashMap};
use std::ffi::OsStr; use std::ffi::OsStr;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use clap::Parser; use clap::Clap;
use fif::files::{mime_extension_lookup, scan_directory, scan_from_walkdir, BUF_SIZE}; use fif::files::{mime_extension_lookup, scan_directory, scan_from_walkdir, BUF_SIZE};
use fif::findings::Findings; use fif::findings::Findings;
use fif::formats::{Format, PowerShell, Shell}; use fif::formats::{Format, PowerShell, Shell};
@ -294,7 +294,6 @@ fn exclude_set_overrides_include_set() {
#[test] #[test]
/// Ensure that badly formed command line arguments are rejected. /// Ensure that badly formed command line arguments are rejected.
fn rejects_bad_args() { fn rejects_bad_args() {
use assert_cmd::Command;
let tests = [ let tests = [
// Non-existent flags: // Non-existent flags:
vec!["fif", "-abcdefghijklmnopqrstuvwxyz"], vec!["fif", "-abcdefghijklmnopqrstuvwxyz"],
@ -306,8 +305,6 @@ fn rejects_bad_args() {
vec!["fif", "-X", "pebis"], vec!["fif", "-X", "pebis"],
// `-e` with nothing but commas: // `-e` with nothing but commas:
vec!["fif", "-e", ",,,,,"], vec!["fif", "-e", ",,,,,"],
// `-x` with nothing but commas:
vec!["fif", "-x", ",,,,,"],
// `-j` with a negative value: // `-j` with a negative value:
vec!["fif", "-j", "-1"], vec!["fif", "-j", "-1"],
// `--prompt` without `--fix`: // `--prompt` without `--fix`:
@ -317,67 +314,10 @@ fn rejects_bad_args() {
]; ];
for test in &tests { for test in &tests {
// first, try testing the flags against the Parameters struct...
assert!(Parameters::try_parse_from(test).is_err(), "Failed to reject {:?}", test); assert!(Parameters::try_parse_from(test).is_err(), "Failed to reject {:?}", test);
// ...then, make sure it actually works against the binary
let mut cmd = Command::cargo_bin("fif").unwrap();
cmd.args(test).assert().failure();
} }
} }
#[test]
/// Ensure that a few simple, well-formed command line argument cases pass
fn accepts_good_args() {
use assert_cmd::Command;
// all of these commands pass either the version or help flag, ensuring that they won't fail for reasons relating
// to filesystem access
let tests = [
vec!["-V"],
vec!["--version"],
vec!["-E", "images", "--version"],
vec!["-h"],
vec!["--help"],
vec!["dir_name", "--version"],
];
for test in &tests {
let mut cmd = Command::cargo_bin("fif").unwrap();
cmd.args(test).assert().success();
}
}
#[test]
/// Ensures that output from the `-V` and `--version` flags is formatted properly.
fn check_version_output() {
use std::string::String;
use assert_cmd::Command;
use regex::Regex;
// test `-V` matches the format of "fif x.y.z"
let mut cmd = Command::cargo_bin("fif").unwrap();
let output = cmd.arg("-V").ok().unwrap().stdout;
let output = String::from_utf8(output).unwrap();
assert!(
Regex::new(r#"fif v([0-9]\.){2}[0-9]"#).unwrap().is_match(output.trim()),
"\"{}\" does not match the expected `-v` format!",
output
);
// test `--version` matches the format of "fif x.y.z (OS, example backend, commit #1234abc)"
let mut cmd = Command::cargo_bin("fif").unwrap();
let output = cmd.arg("--version").ok().unwrap().stdout;
let output = String::from_utf8(output).unwrap();
assert!(
Regex::new(r#"fif v([0-9]\.){2}[0-9] \(.+, .+ backend, (unknown commit|commit #[[:xdigit:]]{7})\)"#)
.unwrap()
.is_match(output.trim()),
"\"{}\" does not match the expected `--version` format!",
output.trim()
);
}
#[test] #[test]
/// Generate random series of bytes and try to identify them. This test makes no assertions and can only fail if the /// Generate random series of bytes and try to identify them. This test makes no assertions and can only fail if the
/// mime database somehow panics or hangs. /// mime database somehow panics or hangs.

View file

@ -30,13 +30,13 @@ pub(crate) static CLAP_VERSION: Lazy<String> = Lazy::new(|| String::from("v") +
/// The version defined in Cargo.toml, prefixed with a v (e.g. "v0.4.0"), followed by the chosen backend and /// The version defined in Cargo.toml, prefixed with a v (e.g. "v0.4.0"), followed by the chosen backend and
/// abbreviated git commit hash in parentheses - For example, "v0.4.0 (XDG-Mime backend, commit #043e097)" /// abbreviated git commit hash in parentheses - For example, "v0.4.0 (XDG-Mime backend, commit #043e097)"
pub static CLAP_LONG_VERSION: Lazy<String> = Lazy::new(|| { pub static CLAP_LONG_VERSION: Lazy<String> = Lazy::new(|| {
// handle cases where GIT_SHA is set to an empty string format!(
let commit = match option_env!("GIT_SHA") { "v{} ({} backend, commit #{})",
Some(hash) if !hash.trim().is_empty() => String::from("commit #") + hash, VERSION.unwrap_or("???"),
_ => String::from("unknown commit"), BACKEND,
}; option_env!("GIT_SHA").unwrap_or("???")
)
format!("v{} ({}, {} backend, {})", VERSION.unwrap_or("???"), os_name(), BACKEND, commit).into() .into()
}); });
/// A [`Mime`] representing the "application/zip" MIME type. /// A [`Mime`] representing the "application/zip" MIME type.