mirror of
https://github.com/jht5945/finding.git
synced 2026-01-12 03:50:04 +08:00
Compare commits
36 Commits
c03ab9ff4c
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
20ba3259d2
|
|||
|
5d2ec01348
|
|||
| d789934de1 | |||
| 17a02c34b9 | |||
| 13a718487b | |||
| bb8103dac9 | |||
| 6f274d9a46 | |||
| b42086b865 | |||
| 1cd44f5cbb | |||
| 0fda440d02 | |||
| 1cbeccfd9a | |||
| e430e037bc | |||
| 5b78fa85bc | |||
| e0a85b1368 | |||
| ca8a3fb848 | |||
| 204e82635a | |||
| 713cbdc67f | |||
| 9818c25f15 | |||
| 68d51461bd | |||
| cb6f3cd4bd | |||
| b2dc1d868c | |||
| 29fea6ac49 | |||
| 63afb268ef | |||
| eefbb3d49e | |||
| 84a0c444a0 | |||
| f9d873659e | |||
| 0e4024337f | |||
| 03bbba3193 | |||
| 39b6cbde6a | |||
| 93d39ecd50 | |||
| 6b7c2b3759 | |||
| 640293989c | |||
| efa006f745 | |||
| 2ce9540577 | |||
| 8008f27518 | |||
| be4a25f0c7 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
|||||||
|
.idea/
|
||||||
# Generated by Cargo
|
# Generated by Cargo
|
||||||
# will have compiled files and executables
|
# will have compiled files and executables
|
||||||
/target/
|
/target/
|
||||||
|
|||||||
392
Cargo.lock
generated
392
Cargo.lock
generated
@@ -1,371 +1,333 @@
|
|||||||
# This file is automatically @generated by Cargo.
|
# This file is automatically @generated by Cargo.
|
||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
|
version = 4
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "argparse"
|
name = "argparse"
|
||||||
version = "0.2.2"
|
version = "0.2.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3f8ebf5827e4ac4fd5946560e6a99776ea73b596d80898f357007317a7141e47"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "arrayref"
|
name = "arrayref"
|
||||||
version = "0.3.5"
|
version = "0.3.9"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "arrayvec"
|
name = "arrayvec"
|
||||||
version = "0.5.1"
|
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"
|
||||||
[[package]]
|
|
||||||
name = "backtrace"
|
|
||||||
version = "0.3.40"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"backtrace-sys 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "backtrace-sys"
|
|
||||||
version = "0.1.32"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"cc 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "base64"
|
name = "base64"
|
||||||
version = "0.10.1"
|
version = "0.13.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8"
|
||||||
"byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bitflags"
|
name = "bitflags"
|
||||||
version = "1.2.1"
|
version = "2.9.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "blake2b_simd"
|
name = "blake2b_simd"
|
||||||
version = "0.5.9"
|
version = "0.5.11"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "afa748e348ad3be8263be728124b24a24f268266f6f5d58af9d75f6a40b5c587"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"arrayref",
|
||||||
"arrayvec 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"arrayvec",
|
||||||
"constant_time_eq 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"constant_time_eq",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "byteorder"
|
name = "byteorder"
|
||||||
version = "1.3.2"
|
version = "1.5.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "cc"
|
|
||||||
version = "1.0.48"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cfg-if"
|
name = "cfg-if"
|
||||||
version = "0.1.10"
|
version = "1.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||||
[[package]]
|
|
||||||
name = "cloudabi"
|
|
||||||
version = "0.0.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "constant_time_eq"
|
name = "constant_time_eq"
|
||||||
version = "0.1.4"
|
version = "0.1.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crossbeam-utils"
|
name = "crossbeam-utils"
|
||||||
version = "0.6.6"
|
version = "0.8.21"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28"
|
||||||
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dirs"
|
name = "dirs"
|
||||||
version = "1.0.5"
|
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 = "3fd78930633bd1c6e35c4b42b1df7b0cbc6bc191146e512bb3bedf243fcc3901"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc",
|
||||||
"redox_users 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"redox_users 0.3.5",
|
||||||
"winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "failure"
|
name = "dirs-next"
|
||||||
version = "0.1.6"
|
version = "2.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"backtrace 0.3.40 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cfg-if",
|
||||||
"failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"dirs-sys-next",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "failure_derive"
|
name = "dirs-sys-next"
|
||||||
version = "0.1.6"
|
version = "0.1.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc",
|
||||||
"quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"redox_users 0.4.6",
|
||||||
"syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
"winapi",
|
||||||
"synstructure 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "finding"
|
name = "finding"
|
||||||
version = "0.1.3"
|
version = "0.2.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"argparse 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"argparse",
|
||||||
"rust_util 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rust_util",
|
||||||
"term 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"term 0.5.2",
|
||||||
"term_size 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"term_size",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fuchsia-cprng"
|
name = "getrandom"
|
||||||
version = "0.1.1"
|
version = "0.1.16"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"libc",
|
||||||
|
"wasi 0.9.0+wasi-snapshot-preview1",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "kernel32-sys"
|
name = "getrandom"
|
||||||
version = "0.2.2"
|
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 = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cfg-if",
|
||||||
"winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc",
|
||||||
|
"wasi 0.11.0+wasi-snapshot-preview1",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lazy_static"
|
name = "lazy_static"
|
||||||
version = "1.4.0"
|
version = "1.5.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "libc"
|
||||||
version = "0.2.66"
|
version = "0.2.171"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libredox"
|
||||||
|
version = "0.1.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags",
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "proc-macro2"
|
||||||
version = "1.0.6"
|
version = "1.0.94"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "quote"
|
name = "quote"
|
||||||
version = "1.0.2"
|
version = "1.0.40"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"proc-macro2",
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rand_core"
|
|
||||||
version = "0.3.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rand_core"
|
|
||||||
version = "0.4.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rand_os"
|
|
||||||
version = "0.1.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rdrand"
|
|
||||||
version = "0.4.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "redox_syscall"
|
name = "redox_syscall"
|
||||||
version = "0.1.56"
|
version = "0.1.57"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "redox_users"
|
name = "redox_users"
|
||||||
version = "0.3.1"
|
version = "0.3.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "de0737333e7a9502c789a36d7c7fa6092a49895d4faa31ca5df163857ded2e9d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"getrandom 0.1.16",
|
||||||
"rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"redox_syscall",
|
||||||
"redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rust-argon2",
|
||||||
"rust-argon2 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "redox_users"
|
||||||
|
version = "0.4.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43"
|
||||||
|
dependencies = [
|
||||||
|
"getrandom 0.2.15",
|
||||||
|
"libredox",
|
||||||
|
"thiserror",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rust-argon2"
|
name = "rust-argon2"
|
||||||
version = "0.5.1"
|
version = "0.8.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4b18820d944b33caa75a71378964ac46f58517c92b6ae5f762636247c09e78fb"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"base64",
|
||||||
"blake2b_simd 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
"blake2b_simd",
|
||||||
"crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"constant_time_eq",
|
||||||
|
"crossbeam-utils",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rust_util"
|
name = "rust_util"
|
||||||
version = "0.1.0"
|
version = "0.6.47"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6bca5d3493eb29d08dc76ee784a78723fe366fec5dfe67ab37da9d50fb868f7c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lazy_static",
|
||||||
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc",
|
||||||
"term 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"term 0.7.0",
|
||||||
"term_size 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"term_size",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustc-demangle"
|
name = "rustversion"
|
||||||
version = "0.1.16"
|
version = "1.0.20"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "1.0.11"
|
version = "2.0.100"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"proc-macro2",
|
||||||
"quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"quote",
|
||||||
"unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"unicode-ident",
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "synstructure"
|
|
||||||
version = "0.12.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "term"
|
name = "term"
|
||||||
version = "0.5.2"
|
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 = "edd106a334b7657c10b7c540a0106114feadeb4dc314513e97df481d5d966f42"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"byteorder",
|
||||||
"dirs 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"dirs",
|
||||||
"winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"winapi",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "term"
|
||||||
|
version = "0.7.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c59df8ac95d96ff9bede18eb7300b0fda5e5d8d90960e76f8e14ae765eedbf1f"
|
||||||
|
dependencies = [
|
||||||
|
"dirs-next",
|
||||||
|
"rustversion",
|
||||||
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "term_size"
|
name = "term_size"
|
||||||
version = "0.3.1"
|
version = "0.3.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1e4129646ca0ed8f45d09b929036bafad5377103edd06e50bf574b353d2b08d9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc",
|
||||||
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
|
"winapi",
|
||||||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-xid"
|
name = "thiserror"
|
||||||
version = "0.2.0"
|
version = "1.0.69"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "winapi"
|
|
||||||
version = "0.2.8"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "winapi"
|
|
||||||
version = "0.3.8"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"thiserror-impl",
|
||||||
"winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winapi-build"
|
name = "thiserror-impl"
|
||||||
version = "0.1.1"
|
version = "1.0.69"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicode-ident"
|
||||||
|
version = "1.0.18"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasi"
|
||||||
|
version = "0.9.0+wasi-snapshot-preview1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasi"
|
||||||
|
version = "0.11.0+wasi-snapshot-preview1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
||||||
|
|
||||||
|
[[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]]
|
[[package]]
|
||||||
name = "winapi-i686-pc-windows-gnu"
|
name = "winapi-i686-pc-windows-gnu"
|
||||||
version = "0.4.0"
|
version = "0.4.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winapi-x86_64-pc-windows-gnu"
|
name = "winapi-x86_64-pc-windows-gnu"
|
||||||
version = "0.4.0"
|
version = "0.4.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||||
[metadata]
|
|
||||||
"checksum argparse 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3f8ebf5827e4ac4fd5946560e6a99776ea73b596d80898f357007317a7141e47"
|
|
||||||
"checksum arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0d382e583f07208808f6b1249e60848879ba3543f57c32277bf52d69c2f0f0ee"
|
|
||||||
"checksum arrayvec 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8"
|
|
||||||
"checksum backtrace 0.3.40 (registry+https://github.com/rust-lang/crates.io-index)" = "924c76597f0d9ca25d762c25a4d369d51267536465dc5064bdf0eb073ed477ea"
|
|
||||||
"checksum backtrace-sys 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)" = "5d6575f128516de27e3ce99689419835fce9643a9b215a14d2b5b685be018491"
|
|
||||||
"checksum base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e"
|
|
||||||
"checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
|
|
||||||
"checksum blake2b_simd 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b83b7baab1e671718d78204225800d6b170e648188ac7dc992e9d6bddf87d0c0"
|
|
||||||
"checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5"
|
|
||||||
"checksum cc 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)" = "f52a465a666ca3d838ebbf08b241383421412fe7ebb463527bba275526d89f76"
|
|
||||||
"checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
|
|
||||||
"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
|
|
||||||
"checksum constant_time_eq 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "995a44c877f9212528ccc74b21a232f66ad69001e40ede5bcee2ac9ef2657120"
|
|
||||||
"checksum crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "04973fa96e96579258a5091af6003abde64af786b860f18622b82e026cca60e6"
|
|
||||||
"checksum dirs 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3fd78930633bd1c6e35c4b42b1df7b0cbc6bc191146e512bb3bedf243fcc3901"
|
|
||||||
"checksum failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f8273f13c977665c5db7eb2b99ae520952fe5ac831ae4cd09d80c4c7042b5ed9"
|
|
||||||
"checksum failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0bc225b78e0391e4b8683440bf2e63c2deeeb2ce5189eab46e2b68c6d3725d08"
|
|
||||||
"checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
|
|
||||||
"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
|
|
||||||
"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
|
||||||
"checksum libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)" = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558"
|
|
||||||
"checksum proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9c9e470a8dc4aeae2dee2f335e8f533e2d4b347e1434e5671afc49b054592f27"
|
|
||||||
"checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe"
|
|
||||||
"checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b"
|
|
||||||
"checksum rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc"
|
|
||||||
"checksum rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071"
|
|
||||||
"checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2"
|
|
||||||
"checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84"
|
|
||||||
"checksum redox_users 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4ecedbca3bf205f8d8f5c2b44d83cd0690e39ee84b951ed649e9f1841132b66d"
|
|
||||||
"checksum rust-argon2 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4ca4eaef519b494d1f2848fc602d18816fed808a981aedf4f1f00ceb7c9d32cf"
|
|
||||||
"checksum rust_util 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5dc9b9d45cf4e9a8a28c1c622f0a2bba9af88b85ec04c494d80605a717c1c022"
|
|
||||||
"checksum rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783"
|
|
||||||
"checksum syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)" = "dff0acdb207ae2fe6d5976617f887eb1e35a2ba52c13c7234c790960cdad9238"
|
|
||||||
"checksum synstructure 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545"
|
|
||||||
"checksum term 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "edd106a334b7657c10b7c540a0106114feadeb4dc314513e97df481d5d966f42"
|
|
||||||
"checksum term_size 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9e5b9a66db815dcfd2da92db471106457082577c3c278d4138ab3e3b4e189327"
|
|
||||||
"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
|
|
||||||
"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
|
|
||||||
"checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6"
|
|
||||||
"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
|
|
||||||
"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
|
||||||
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "finding"
|
name = "finding"
|
||||||
version = "0.1.3"
|
version = "0.2.1"
|
||||||
authors = ["Hatter Jiang <jht5945@gmail.com>"]
|
authors = ["Hatter Jiang <jht5945@gmail.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
description = "command line finding tool"
|
description = "command line finding tool"
|
||||||
@@ -12,4 +12,4 @@ license = "MIT"
|
|||||||
argparse = "0.2.2"
|
argparse = "0.2.2"
|
||||||
term = "0.5.2"
|
term = "0.5.2"
|
||||||
term_size = "0.3.1"
|
term_size = "0.3.1"
|
||||||
rust_util = "0.1.0"
|
rust_util = "0.6.3"
|
||||||
|
|||||||
1
_config.yml
Normal file
1
_config.yml
Normal file
@@ -0,0 +1 @@
|
|||||||
|
theme: jekyll-theme-cayman
|
||||||
@@ -1,28 +1,60 @@
|
|||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
|
cell::Cell,
|
||||||
fs::File,
|
fs::File,
|
||||||
path::Path,
|
path::Path,
|
||||||
io::prelude::*,
|
io::prelude::*,
|
||||||
};
|
};
|
||||||
|
use rust_util::{ XResult, new_box_error, };
|
||||||
|
|
||||||
use rust_util::{
|
#[derive(Debug)]
|
||||||
XResult,
|
pub struct MatchLine {
|
||||||
new_box_error,
|
pub line_number: usize,
|
||||||
};
|
pub line_string: String,
|
||||||
|
}
|
||||||
|
|
||||||
pub fn read_file_content(file: &Path, large_file_len: u64) -> XResult<String> {
|
impl MatchLine {
|
||||||
|
pub fn new(line_number: usize, line_string: String) -> MatchLine {
|
||||||
|
MatchLine { line_number, line_string, }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct CountCell( Cell<u64> );
|
||||||
|
|
||||||
|
impl CountCell {
|
||||||
|
pub fn new() -> CountCell {
|
||||||
|
CountCell( Cell::new(0_u64) )
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn get(&self) -> u64 {
|
||||||
|
self.0.get()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn add(&self, i: u64) {
|
||||||
|
self.0.set(self.0.get() + i);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn add_one(&self) {
|
||||||
|
self.add(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn read_file_content<P: AsRef<Path>>(p: P, len_of_large_file: u64) -> XResult<String> {
|
||||||
|
let file = p.as_ref();
|
||||||
if !file.exists() {
|
if !file.exists() {
|
||||||
return Err(new_box_error(&format!("File not exists: {:?}", file)));
|
return Err(new_box_error(&format!("File not exists: {:?}", file)));
|
||||||
}
|
}
|
||||||
if !file.is_file() {
|
if !file.is_file() {
|
||||||
return Err(new_box_error(&format!("File is not file: {:?}", file)));
|
return Err(new_box_error(&format!("File is not a file: {:?}", file)));
|
||||||
}
|
}
|
||||||
let file_len = file.metadata()?.len();
|
let file_len = file.metadata()?.len();
|
||||||
if file_len > large_file_len {
|
if file_len >= len_of_large_file {
|
||||||
return Err(new_box_error(&format!("File too large: {:?}, len: {}", file, file_len)));
|
return Err(new_box_error(&format!("File too large: {:?}, len: {}", file, file_len)));
|
||||||
}
|
}
|
||||||
let mut f = File::open(file)?;
|
let mut f = File::open(file)?;
|
||||||
let mut content = String::new();
|
let mut content = String::with_capacity(file_len as usize);
|
||||||
f.read_to_string(&mut content)?;
|
f.read_to_string(&mut content)?;
|
||||||
|
|
||||||
Ok(content)
|
Ok(content)
|
||||||
|
|||||||
282
src/main.rs
282
src/main.rs
@@ -1,284 +1,224 @@
|
|||||||
extern crate argparse;
|
extern crate argparse;
|
||||||
extern crate term;
|
extern crate term;
|
||||||
extern crate term_size;
|
extern crate term_size;
|
||||||
|
#[macro_use]
|
||||||
extern crate rust_util;
|
extern crate rust_util;
|
||||||
|
|
||||||
mod opt;
|
mod opt;
|
||||||
mod local_util;
|
mod local_util;
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
cell::RefCell,
|
|
||||||
path::Path,
|
path::Path,
|
||||||
time::SystemTime,
|
time::{ Duration, SystemTime },
|
||||||
};
|
};
|
||||||
|
|
||||||
use opt::*;
|
use opt::*;
|
||||||
use rust_util::{
|
use rust_util::{
|
||||||
XResult,
|
XResult,
|
||||||
new_box_error,
|
new_box_error,
|
||||||
util_file::*,
|
util_file::*,
|
||||||
util_size::*,
|
util_size::*,
|
||||||
util_msg::*,
|
|
||||||
};
|
};
|
||||||
use local_util::*;
|
use rust_util::util_msg::{MessageType, print_lastline, print_message, get_term_width_message, print_color_and_flush};
|
||||||
|
use local_util::{ CountCell, MatchLine, read_file_content };
|
||||||
|
|
||||||
|
const EMPTY: &str = "";
|
||||||
const VERSION: &str = env!("CARGO_PKG_VERSION");
|
const VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||||
const GIT_HASH: &str = env!("GIT_HASH");
|
const GIT_HASH: &str = env!("GIT_HASH");
|
||||||
|
|
||||||
fn print_version() {
|
fn print_version(options: &Options) {
|
||||||
println!(r#"finding {} - {}
|
println!(r#"finding {} - {}
|
||||||
Copyright (C) 2019 Hatter Jiang.
|
Copyright (C) 2019-2020 Hatter Jiang.
|
||||||
License MIT <https://opensource.org/licenses/MIT>
|
License MIT <https://opensource.org/licenses/MIT>
|
||||||
|
|
||||||
Written by Hatter Jiang"#, VERSION, &GIT_HASH[0..7]);
|
Written by Hatter Jiang"#, VERSION, &GIT_HASH[0..7]);
|
||||||
|
if options.verbose {
|
||||||
|
debugging!("Version: {}", VERSION);
|
||||||
|
debugging!("Git hash: {}", GIT_HASH);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn clear_n_print_message(mt: MessageType, message: &str) {
|
||||||
|
print_lastline(EMPTY);
|
||||||
|
print_message(mt, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn find_huge_files(options: &Options, dir_path: &Path) {
|
fn find_huge_files(options: &Options, dir_path: &Path) {
|
||||||
let total_file_count_cell = RefCell::new(0u64);
|
let total_file_count = CountCell::new();
|
||||||
let huge_file_count_cell = RefCell::new(0u64);
|
let huge_file_count = CountCell::new();
|
||||||
let huge_file_size_cell = RefCell::new(0u64);
|
let huge_file_size = CountCell::new();
|
||||||
walk_dir(&dir_path, &|_, _| (/* do not process error */), &|p| {
|
walk_dir(&dir_path, &|_, _| (/* do not process error */), &|p| { // process file
|
||||||
total_file_count_cell.replace_with(|&mut c| c + 1);
|
total_file_count.add_one();
|
||||||
|
let p_str = match p.to_str() {
|
||||||
|
Some(s) => s, None => return,
|
||||||
|
};
|
||||||
match p.metadata() {
|
match p.metadata() {
|
||||||
Err(err) => {
|
Err(err) => if options.verbose {
|
||||||
if options.verbose {
|
clear_n_print_message(MessageType::WARN, &format!("Read file {} meta failed: {}", p_str, err));
|
||||||
if let Some(p_str) = p.to_str() {
|
|
||||||
print_lastline("");
|
|
||||||
print_message(MessageType::WARN, &format!("Read file {} meta failed: {}", p_str, err));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
},
|
},
|
||||||
Ok(metadata) => {
|
Ok(metadata) => {
|
||||||
let len = metadata.len();
|
let len = metadata.len();
|
||||||
if len >= options.parsed_huge_file_size {
|
if len >= options.parsed_huge_file_size {
|
||||||
huge_file_count_cell.replace_with(|&mut c| c + 1);
|
huge_file_count.add_one();
|
||||||
huge_file_size_cell.replace_with(|&mut c| c + len);
|
huge_file_size.add(len);
|
||||||
match p.to_str() {
|
clear_n_print_message(MessageType::OK, &format!("{} [{}]", p_str, get_display_size(len as i64)));
|
||||||
None => (),
|
|
||||||
Some(p_str) => {
|
|
||||||
print_lastline("");
|
|
||||||
print_message(MessageType::OK, &format!("{} [{}]", p_str, get_display_size(len as i64)));
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}, &|p| {
|
}, &|p| { // process path
|
||||||
match p.to_str() {
|
let p_str = match p.to_str() {
|
||||||
None => (),
|
Some(s) => s, None => return false,
|
||||||
Some(p_str) => {
|
};
|
||||||
if options.skip_link_dir && is_symlink(p) {
|
let is_skip_link_and_is_link = options.skip_link_dir && is_symlink(p);
|
||||||
|
if is_skip_link_and_is_link {
|
||||||
if options.verbose {
|
if options.verbose {
|
||||||
print_lastline("");
|
clear_n_print_message(MessageType::DEBUG, &format!("Skip link dir: {}", p_str));
|
||||||
print_message(MessageType::INFO, &format!("Skip link dir: {}", p_str));
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
print_lastline(&get_term_width_message(&format!("Scanning: {}", p_str), 10))
|
|
||||||
},
|
|
||||||
}
|
|
||||||
true
|
|
||||||
}).unwrap_or(());
|
|
||||||
print_lastline("");
|
|
||||||
print_message(MessageType::OK, &format!("Total file count: {}, huge file count: {}, total huge file size: {}",
|
|
||||||
total_file_count_cell.into_inner(),
|
|
||||||
huge_file_count_cell.into_inner(),
|
|
||||||
get_display_size(huge_file_size_cell.into_inner() as i64)));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
struct MatchLine {
|
|
||||||
line_number: usize,
|
|
||||||
line_string: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl MatchLine {
|
|
||||||
fn new(l_no: usize, l_str: String) -> MatchLine {
|
|
||||||
MatchLine {
|
|
||||||
line_number: l_no,
|
|
||||||
line_string: l_str,
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
print_lastline(&get_term_width_message(&format!("Scanning: {}", p_str), 10));
|
||||||
}
|
}
|
||||||
|
!is_skip_link_and_is_link
|
||||||
|
}).ok();
|
||||||
|
clear_n_print_message(MessageType::OK, &format!("Total file count: {}, huge file count: {}, total huge file size: {}",
|
||||||
|
total_file_count.get(),
|
||||||
|
huge_file_count.get(),
|
||||||
|
get_display_size(huge_file_size.get() as i64)));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn match_lines(tag: &str, content: &str, options: &Options) -> bool {
|
fn match_lines(tag: &str, content: &str, options: &Options) -> bool {
|
||||||
let search_text = &options.search_text;
|
let search_text = &options.search_text;
|
||||||
let lines = content.lines();
|
let lines = content.lines();
|
||||||
let mut match_lines_vec = vec![];
|
let mut match_lines_vec = vec![];
|
||||||
let mut l_no = 0usize;
|
let the_search_text = &iff!(options.ignore_case, search_text.to_lowercase(), search_text.to_string());
|
||||||
let the_search_text = &match options.ignore_case {
|
for (line_no, ln) in lines.enumerate() {
|
||||||
true => search_text.to_lowercase(),
|
|
||||||
false => search_text.to_string(),
|
|
||||||
};
|
|
||||||
for ln in lines {
|
|
||||||
if options.filter_large_line && ln.len() as u64 >= options.parsed_large_line_size {
|
if options.filter_large_line && ln.len() as u64 >= options.parsed_large_line_size {
|
||||||
if options.verbose {
|
if options.verbose {
|
||||||
print_lastline("");
|
clear_n_print_message(MessageType::DEBUG, &format!("Skip large line: {} chars", ln.len()));
|
||||||
print_message(MessageType::INFO, &format!("Skip large line: {} bytes", ln.len()));
|
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let matches = match options.ignore_case {
|
let matches = iff!(options.ignore_case, ln.to_lowercase().contains(the_search_text), ln.contains(the_search_text));
|
||||||
true => ln.to_lowercase().contains(the_search_text),
|
let matches_line_content = match &options.filter_line_content {
|
||||||
false => ln.contains(the_search_text),
|
c if c.is_empty() => true,
|
||||||
|
c => ln.contains(c),
|
||||||
};
|
};
|
||||||
let mut matches_line_content = true;
|
|
||||||
if !options.filter_line_content.is_empty(){
|
|
||||||
if ! ln.contains(options.filter_line_content.as_str()) {
|
|
||||||
matches_line_content = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if matches && matches_line_content {
|
if matches && matches_line_content {
|
||||||
match_lines_vec.push(MatchLine::new(l_no, ln.to_string()));
|
match_lines_vec.push(MatchLine::new(line_no, ln.to_string()));
|
||||||
}
|
}
|
||||||
l_no += 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut matches_any = false;
|
|
||||||
if !match_lines_vec.is_empty() {
|
if !match_lines_vec.is_empty() {
|
||||||
print_lastline("");
|
clear_n_print_message(MessageType::OK, &format!("Find in {}:", tag));
|
||||||
print_message(MessageType::OK, &format!("Find in {}:", tag));
|
for match_line in &match_lines_vec {
|
||||||
for i in 0..match_lines_vec.len() {
|
print!("{}: ", match_line.line_number + 1);
|
||||||
print!("{}: ", match_lines_vec[i].line_number + 1);
|
if options.ignore_case {
|
||||||
match options.ignore_case {
|
println!("{}", match_line.line_string);
|
||||||
true => println!("{}", match_lines_vec[i].line_string),
|
} else {
|
||||||
false => {
|
let parts = match_line.line_string.split(search_text).collect::<Vec<_>>();
|
||||||
let ss: Vec<&str> = match_lines_vec[i].line_string.split(search_text).collect();
|
for (i, part) in parts.iter().enumerate() {
|
||||||
for j in 0..ss.len() {
|
if i != 0 {
|
||||||
print!("{}", ss[j]);
|
print_color_and_flush( Some(term::color::RED), true, search_text);
|
||||||
if j < ss.len() -1 {
|
|
||||||
print_color(Some(term::color::RED), true, search_text);
|
|
||||||
}
|
}
|
||||||
|
print!("{}", part);
|
||||||
}
|
}
|
||||||
println!();
|
println!();
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
matches_any = true;
|
|
||||||
}
|
}
|
||||||
matches_any
|
!match_lines_vec.is_empty()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn find_text_files(options: &Options, dir_path: &Path) {
|
fn find_text_files(options: &Options, dir_path: &Path) {
|
||||||
if options.search_text.is_empty() {
|
if options.search_text.is_empty() {
|
||||||
print_message(MessageType::ERROR, "Param search_text cannot be empty.");
|
failure!("Param search_text cannot be empty.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if options.ignore_case {
|
if options.ignore_case {
|
||||||
print_message(MessageType::WARN, "Using ignore case mode, highlight print is disabled.");
|
warning!("Using ignore case mode, highlight print is disabled.");
|
||||||
}
|
}
|
||||||
let file_exts = match options.file_ext.as_str() {
|
let file_exts = match &options.file_ext {
|
||||||
"" => vec![],
|
ext if ext.is_empty() => vec![],
|
||||||
ext => {
|
ext => ext.split(',').map(|s| s.trim()).filter(|s| !s.is_empty()).map(|s| ".".to_owned() + s).collect(),
|
||||||
ext.split(',').map(|s| s.trim()).filter(|s| !s.is_empty()).map(|s| String::from(".") + s).collect()
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
let total_file_count_cell = RefCell::new(0u64);
|
let total_file_count = CountCell::new();
|
||||||
let scaned_file_count_cell = RefCell::new(0u64);
|
let scaned_file_count = CountCell::new();
|
||||||
let matched_file_count_cell = RefCell::new(0u64);
|
let matched_file_count = CountCell::new();
|
||||||
let total_dir_count_cell = RefCell::new(0u64);
|
let total_dir_count = CountCell::new();
|
||||||
let scaned_dir_count_cell = RefCell::new(0u64);
|
let scaned_dir_count = CountCell::new();
|
||||||
walk_dir(&dir_path, &|_, _| (/* do not process error */), &|p| {
|
walk_dir(&dir_path, &|_, _| (/* do not process error */), &|p| { // process file
|
||||||
total_file_count_cell.replace_with(|&mut c| c + 1);
|
total_file_count.add_one();
|
||||||
let p_str = match p.to_str() {
|
let p_str = match p.to_str() {
|
||||||
None => return,
|
Some(s) => s, None => return,
|
||||||
Some(s) => s,
|
|
||||||
};
|
};
|
||||||
if !file_exts.is_empty() {
|
if !file_exts.is_empty() && !file_exts.iter().any(|file_ext| p_str.to_lowercase().ends_with(file_ext)) {
|
||||||
let mut file_ext_matches = false;
|
|
||||||
for file_ext in &file_exts {
|
|
||||||
if p_str.to_lowercase().ends_with(file_ext) {
|
|
||||||
file_ext_matches = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ! file_ext_matches {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
if !options.filter_file_name.is_empty() && !p_str.contains(options.filter_file_name.as_str()) {
|
||||||
if !options.filter_file_name.is_empty() {
|
|
||||||
if ! p_str.contains(options.filter_file_name.as_str()) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
let file_content = match read_file_content(p, options.parsed_large_text_file_size) {
|
let file_content = match read_file_content(p, options.parsed_large_text_file_size) {
|
||||||
Err(err) => {
|
Ok(c) => c, Err(err) => {
|
||||||
if options.verbose {
|
if options.verbose { clear_n_print_message(MessageType::WARN, &format!("Read file {} failed: {}", p_str, err)); }
|
||||||
print_lastline("");
|
|
||||||
print_message(MessageType::WARN, &format!("Read file {} failed: {}", p_str, err));
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
},
|
},
|
||||||
Ok(c) => c,
|
|
||||||
};
|
};
|
||||||
scaned_file_count_cell.replace_with(|&mut c| c + 1);
|
scaned_file_count.add_one();
|
||||||
if match_lines(p_str, &file_content, &options) {
|
if match_lines(p_str, &file_content, &options) {
|
||||||
matched_file_count_cell.replace_with(|&mut c| c + 1);
|
matched_file_count.add_one();
|
||||||
}
|
}
|
||||||
}, &|p| {
|
}, &|p| { // process path
|
||||||
total_dir_count_cell.replace_with(|&mut c| c + 1);
|
total_dir_count.add_one();
|
||||||
match p.to_str() {
|
let p_str = match p.to_str() {
|
||||||
None => (),
|
Some(s) => s, None => return false,
|
||||||
Some(p_str) => {
|
};
|
||||||
if (! options.scan_dot_git) && p_str.ends_with("/.git") {
|
if (!options.scan_dot_git_dir) && p_str.ends_with("/.git") {
|
||||||
if options.verbose {
|
if options.verbose { clear_n_print_message(MessageType::DEBUG, &format!("Skip .git dir: {}", p_str)); }
|
||||||
print_lastline("");
|
return false;
|
||||||
print_message(MessageType::INFO, &format!("Skip .git dir: {}", p_str));
|
|
||||||
}
|
}
|
||||||
|
if options.skip_target_dir && p_str.ends_with("/target") {
|
||||||
|
if options.verbose { clear_n_print_message(MessageType::DEBUG, &format!("Skip target dir: {}", p_str)); }
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if options.skip_dot_dir && p_str.contains("/.") {
|
if options.skip_dot_dir && p_str.contains("/.") {
|
||||||
|
if options.verbose { clear_n_print_message(MessageType::DEBUG, &format!("Skip dot(.) dir: {}", p_str)); }
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if options.skip_link_dir && is_symlink(p) {
|
if options.skip_link_dir && is_symlink(p) {
|
||||||
if options.verbose {
|
if options.verbose { clear_n_print_message(MessageType::DEBUG, &format!("Skip link dir: {}", p_str)); }
|
||||||
print_lastline("");
|
|
||||||
print_message(MessageType::INFO, &format!("Skip link dir: {}", p_str));
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
scaned_dir_count_cell.replace_with(|&mut c| c + 1);
|
scaned_dir_count.add_one();
|
||||||
print_lastline(&get_term_width_message(&format!("Scanning: {}", p_str), 10))
|
print_lastline(&get_term_width_message(&format!("Scanning: {}", p_str), 10));
|
||||||
},
|
|
||||||
}
|
|
||||||
true
|
true
|
||||||
}).unwrap_or(());
|
}).ok();
|
||||||
print_lastline("");
|
print_lastline(EMPTY);
|
||||||
print_message(MessageType::OK, &format!("Total dir count: {}, scaned dir count: {}",
|
success!("Total dir count: {}, scaned dir count: {}",
|
||||||
total_dir_count_cell.into_inner(),
|
total_dir_count.get(),
|
||||||
scaned_dir_count_cell.into_inner()));
|
scaned_dir_count.get());
|
||||||
print_message(MessageType::OK, &format!("Total file count: {}, scaned file count: {}, matched file count: {}",
|
success!("Total file count: {}, scaned file count: {}, matched file count: {}",
|
||||||
total_file_count_cell.into_inner(),
|
total_file_count.get(),
|
||||||
scaned_file_count_cell.into_inner(),
|
scaned_file_count.get(),
|
||||||
matched_file_count_cell.into_inner()));
|
matched_file_count.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn main() -> XResult<()> {
|
fn main() -> XResult<()> {
|
||||||
let options = Options::new_and_parse_args()?;
|
let options = Options::new_and_parse_args()?;
|
||||||
|
|
||||||
if options.version {
|
if options.version {
|
||||||
print_version();
|
print_version(&options);
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
let dir_path = match get_absolute_path(&options.dir) {
|
let dir_path = match get_absolute_path(&options.dir) {
|
||||||
None => {
|
|
||||||
return Err(new_box_error(&format!("Cannot find dir: {}", options.dir)));
|
|
||||||
},
|
|
||||||
Some(path) => path,
|
Some(path) => path,
|
||||||
|
None => return Err(new_box_error(&format!("Cannot find dir: {}", options.dir))),
|
||||||
};
|
};
|
||||||
let start = SystemTime::now();
|
let start = SystemTime::now();
|
||||||
match options.target.as_str() {
|
match options.target.as_str() {
|
||||||
"huge" | "hugefile" => find_huge_files(&options, &dir_path),
|
"huge" | "hugefile" => find_huge_files(&options, &dir_path),
|
||||||
"text" => find_text_files(&options, &dir_path),
|
"text" => find_text_files(&options, &dir_path),
|
||||||
unknown => {
|
others => return Err(new_box_error(&format!("Unknown command: {}", others))),
|
||||||
return Err(new_box_error(&format!("Unknown command: {}", unknown)));
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
let cost_millis = SystemTime::now().duration_since(start.clone()).unwrap().as_millis();
|
let cost_millis = SystemTime::now().duration_since(start).unwrap_or_else(|_| Duration::from_millis(0)).as_millis();
|
||||||
print_message(MessageType::OK, &format!("Finding finished, cost {} ms", cost_millis));
|
success!("Finding finished, cost {} ms", cost_millis);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
18
src/opt.rs
18
src/opt.rs
@@ -1,10 +1,5 @@
|
|||||||
|
use argparse::{ ArgumentParser, StoreTrue, Store, };
|
||||||
use argparse::{ArgumentParser, StoreTrue, Store};
|
use rust_util::{ XResult, util_size::*, };
|
||||||
|
|
||||||
use rust_util::{
|
|
||||||
XResult,
|
|
||||||
util_size::*,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub struct Options {
|
pub struct Options {
|
||||||
pub version: bool,
|
pub version: bool,
|
||||||
@@ -19,9 +14,10 @@ pub struct Options {
|
|||||||
pub filter_large_line: bool,
|
pub filter_large_line: bool,
|
||||||
pub large_line_size: String,
|
pub large_line_size: String,
|
||||||
pub parsed_large_line_size: u64,
|
pub parsed_large_line_size: u64,
|
||||||
pub scan_dot_git: bool,
|
pub scan_dot_git_dir: bool,
|
||||||
pub skip_dot_dir: bool,
|
pub skip_dot_dir: bool,
|
||||||
pub skip_link_dir: bool,
|
pub skip_link_dir: bool,
|
||||||
|
pub skip_target_dir: bool,
|
||||||
pub filter_file_name: String,
|
pub filter_file_name: String,
|
||||||
pub filter_line_content: String,
|
pub filter_line_content: String,
|
||||||
pub verbose: bool,
|
pub verbose: bool,
|
||||||
@@ -43,9 +39,10 @@ impl Options {
|
|||||||
filter_large_line: false,
|
filter_large_line: false,
|
||||||
large_line_size: String::from("10KB"),
|
large_line_size: String::from("10KB"),
|
||||||
parsed_large_line_size: 0u64,
|
parsed_large_line_size: 0u64,
|
||||||
scan_dot_git: false,
|
scan_dot_git_dir: false,
|
||||||
skip_dot_dir: false,
|
skip_dot_dir: false,
|
||||||
skip_link_dir: false,
|
skip_link_dir: false,
|
||||||
|
skip_target_dir: false,
|
||||||
filter_file_name: String::new(),
|
filter_file_name: String::new(),
|
||||||
filter_line_content: String::new(),
|
filter_line_content: String::new(),
|
||||||
verbose: false,
|
verbose: false,
|
||||||
@@ -65,9 +62,10 @@ impl Options {
|
|||||||
ap.refer(&mut self.ignore_case).add_option(&["-i", "--ignore-case"], StoreTrue, "Ignore case, default false");
|
ap.refer(&mut self.ignore_case).add_option(&["-i", "--ignore-case"], StoreTrue, "Ignore case, default false");
|
||||||
ap.refer(&mut self.filter_large_line).add_option(&["--filter-large-line"], StoreTrue, "Filter large line");
|
ap.refer(&mut self.filter_large_line).add_option(&["--filter-large-line"], StoreTrue, "Filter large line");
|
||||||
ap.refer(&mut self.large_line_size).add_option(&["--large-line-size"], Store, "Large line, default 10KB");
|
ap.refer(&mut self.large_line_size).add_option(&["--large-line-size"], Store, "Large line, default 10KB");
|
||||||
ap.refer(&mut self.scan_dot_git).add_option(&["--scan-dot-git"], StoreTrue, "Scan dot git");
|
ap.refer(&mut self.scan_dot_git_dir).add_option(&["--scan-dot-git"], StoreTrue, "Scan dot git");
|
||||||
ap.refer(&mut self.skip_dot_dir).add_option(&["--skip-dot-dir"], StoreTrue, "Skipt dot dir [Text Mode]");
|
ap.refer(&mut self.skip_dot_dir).add_option(&["--skip-dot-dir"], StoreTrue, "Skipt dot dir [Text Mode]");
|
||||||
ap.refer(&mut self.skip_link_dir).add_option(&["--skip-link-dir"], StoreTrue, "Skip link dir");
|
ap.refer(&mut self.skip_link_dir).add_option(&["--skip-link-dir"], StoreTrue, "Skip link dir");
|
||||||
|
ap.refer(&mut self.skip_target_dir).add_option(&["--skip-target-dir"], StoreTrue, "Skip target dir");
|
||||||
ap.refer(&mut self.filter_file_name).add_option(&["--filter-file-name"], Store, "Filter file name [Text Mode]");
|
ap.refer(&mut self.filter_file_name).add_option(&["--filter-file-name"], Store, "Filter file name [Text Mode]");
|
||||||
ap.refer(&mut self.filter_line_content).add_option(&["--filter-line-content"], Store, "Filter line content [Text Mode]");
|
ap.refer(&mut self.filter_line_content).add_option(&["--filter-line-content"], Store, "Filter line content [Text Mode]");
|
||||||
ap.refer(&mut self.version).add_option(&["-v", "--version"], StoreTrue, "Print version");
|
ap.refer(&mut self.version).add_option(&["-v", "--version"], StoreTrue, "Print version");
|
||||||
|
|||||||
Reference in New Issue
Block a user