diff --git a/.github/workflows/cargo-audit.yml b/.github/workflows/cargo-audit.yml deleted file mode 100644 index 796a0cd..0000000 --- a/.github/workflows/cargo-audit.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: cargo-audit - -on: - push: - paths: - - "**/Cargo.toml" - - "**/Cargo.lock" - pull_request: - schedule: - - cron: "0 0 * * *" - -jobs: - audit: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest, windows-latest] - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/audit-check@v1 - with: - args: --color=always - token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/cargo-clippy.yml b/.github/workflows/cargo-clippy.yml deleted file mode 100644 index 3b459a8..0000000 --- a/.github/workflows/cargo-clippy.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: cargo-clippy - -on: - push: - pull_request: - -jobs: - clippy: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest, windows-latest] - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: nightly - override: true - components: clippy - - uses: actions-rs/clippy-check@v1 - with: - args: --all-targets --all-features --color=always -- -D warnings -D clippy::all - token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/cargo-fmt.yml b/.github/workflows/cargo-fmt.yml deleted file mode 100644 index 23fb9e8..0000000 --- a/.github/workflows/cargo-fmt.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: cargo-fmt - -on: - push: - pull_request: - -jobs: - fmt: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - components: rustfmt - - uses: actions-rs/cargo@v1 - with: - command: fmt - args: -- --check --color=always diff --git a/.github/workflows/cargo-test.yml b/.github/workflows/cargo-test.yml deleted file mode 100644 index d827bca..0000000 --- a/.github/workflows/cargo-test.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: cargo-test - -on: - push: - pull_request: - -jobs: - test-unix: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest, macos-latest] - steps: - - uses: actions/checkout@v2 - - uses: cachix/install-nix-action@v12 - with: - nix_path: nixpkgs=channel:nixos-stable - # - uses: cachix/cachix-action@v8 - # with: - # name: zoxide - # authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" - - run: nix-shell --pure --run "cargo test --all-features --all-targets --color=always --no-fail-fast" - test-windows: - runs-on: windows-latest - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - uses: actions-rs/cargo@v1 - with: - command: test - args: --all-features --all-targets --color=always --no-fail-fast diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..389d06b --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,26 @@ +name: ci + +on: + push: + branches: + - main + pull_request: + +jobs: + ci: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/install@v0.1 + if: ${{ matrix.os == 'windows-latest' }} + with: + crate: cargo-audit + version: latest + - uses: cachix/install-nix-action@v12 + if: ${{ matrix.os != 'windows-latest' }} + with: + nix_path: nixpkgs=channel:nixos-stable + - run: make test diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c756b34..8dcfeeb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -62,7 +62,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: tag_name: ${{ github.ref }} - release_name: Release ${{ github.ref }} + release_name: ${{ github.ref }} - uses: actions/download-artifact@v2 diff --git a/.gitignore b/.gitignore index bca6f9b..89b1201 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,13 @@ -# Generated by Cargo -# will have compiled files and executables +### Custom ### +.vscode/ + +### Rust ### +# Compiled files and executables debug/ target/ -# These are backup files generated by rustfmt +# Backup files generated by rustfmt **/*.rs.bk + +### Python ### +.mypy_cache/ diff --git a/Cargo.lock b/Cargo.lock index 9cf9598..7e6e92d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,15 +2,21 @@ # It is not intended for manual editing. [[package]] name = "anyhow" -version = "1.0.34" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf8dcb5b4bbaa28653b647d8c77bd4ed40183b48882e130c1f1ffb73de069fd7" +checksum = "28b2cd92db5cbd74e8e5028f7e27dd7aa3090e89e4f2a197cc7c8dfb69c7063b" + +[[package]] +name = "arrayvec" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" [[package]] name = "askama" -version = "0.10.3" +version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70a6e7ebd44d0047fd48206c83c5cd3214acc7b9d87f001da170145c47ef7d12" +checksum = "d298738b6e47e1034e560e5afe63aa488fea34e25ec11b855a76f0d7b8e73134" dependencies = [ "askama_derive", "askama_escape", @@ -19,13 +25,12 @@ dependencies = [ [[package]] name = "askama_derive" -version = "0.10.3" +version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1d7169690c4f56343dcd821ab834972a22570a2662a19a84fd7775d5e1c3881" +checksum = "ca2925c4c290382f9d2fa3d1c1b6a63fa1427099721ecca4749b154cc9c25522" dependencies = [ "askama_shared", "proc-macro2", - "quote", "syn", ] @@ -37,9 +42,9 @@ checksum = "90c108c1a94380c89d2215d0ac54ce09796823cca0fd91b299cfff3b33e346fb" [[package]] name = "askama_shared" -version = "0.10.4" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62fc272363345c8cdc030e4c259d9d028237f8b057dc9bb327772a257bde6bb5" +checksum = "2582b77e0f3c506ec4838a25fa8a5f97b9bed72bb6d3d272ea1c031d8bd373bc" dependencies = [ "askama_escape", "nom", @@ -50,10 +55,11 @@ dependencies = [ [[package]] name = "assert_cmd" -version = "1.0.1" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c88b9ca26f9c16ec830350d309397e74ee9abdfd8eb1f71cb6ecc71a3fc818da" +checksum = "f2475b58cd94eb4f70159f4fd8844ba3b807532fe3131b3373fae060bbe30396" dependencies = [ + "bstr", "doc-comment", "predicates", "predicates-core", @@ -80,9 +86,9 @@ checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" [[package]] name = "bincode" -version = "1.3.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f30d3a39baa26f9651f17b375061f3233dde33424a8b72b0dbe93a68a0bc896d" +checksum = "d175dfa69e619905c4c3cdb7c3c203fa3bdd5d51184e3afdb2742c0280493772" dependencies = [ "byteorder", "serde", @@ -94,18 +100,35 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" +[[package]] +name = "bitvec" +version = "0.19.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8942c8d352ae1838c9dda0b0ca2ab657696ef2232a20147cf1b30ae1a9cb4321" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + +[[package]] +name = "bstr" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a40b47ad93e1a5404e6c18dec46b628214fee441c70f4ab5d6942142cc268a3d" +dependencies = [ + "lazy_static", + "memchr", + "regex-automata", +] + [[package]] name = "byteorder" version = "1.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" -[[package]] -name = "cfg-if" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" - [[package]] name = "cfg-if" version = "1.0.0" @@ -156,15 +179,15 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "dirs-sys-next", ] [[package]] name = "dirs-sys-next" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99de365f605554ae33f115102a02057d4fc18b01f3284d6870be0938743cfe7d" +checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" dependencies = [ "libc", "redox_users", @@ -184,14 +207,31 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2641c4a7c0c4101df53ea572bffdc561c146f6c2eb09e4df02bc4811e3feeb4" [[package]] -name = "getrandom" -version = "0.1.15" +name = "funty" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc587bc0ec293155d5bfa6b9891ec18a1e330c234f896ea47fbada4cadbe47e6" +checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7" + +[[package]] +name = "getrandom" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" dependencies = [ - "cfg-if 0.1.10", + "cfg-if", "libc", - "wasi", + "wasi 0.9.0+wasi-snapshot-preview1", +] + +[[package]] +name = "getrandom" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.10.2+wasi-snapshot-preview1", ] [[package]] @@ -208,27 +248,27 @@ checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" [[package]] name = "heck" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" +checksum = "87cbf45460356b7deeb5e3415b5563308c0a9b057c85e12b06ad551f98d0a6ac" dependencies = [ "unicode-segmentation", ] [[package]] name = "hermit-abi" -version = "0.1.17" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aca5565f760fb5b220e499d72710ed156fdb74e631659e99377d9ebfbd13ae8" +checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c" dependencies = [ "libc", ] [[package]] name = "indexmap" -version = "1.6.0" +version = "1.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55e2e4c765aa53a0424761bf9f41aa7a6ac1efa87238f59560640e27fca028f2" +checksum = "824845a0bf897a9042383849b02c1bc219c2383772efcd5c6f9766fa4b81aef3" dependencies = [ "autocfg", "hashbrown", @@ -241,10 +281,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] -name = "libc" -version = "0.2.80" +name = "lexical-core" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d58d1b70b004888f764dfbf6a26a3b0342a1632d33968e4a179d8011c760614" +checksum = "21f866863575d0e1d654fbeeabdc927292fdf862873dc3c96c6f753357e13374" +dependencies = [ + "arrayvec", + "bitflags", + "cfg-if", + "ryu", + "static_assertions", +] + +[[package]] +name = "libc" +version = "0.2.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8916b1f6ca17130ec6568feccee27c156ad12037880833a3b842a823236502e7" [[package]] name = "memchr" @@ -254,10 +307,13 @@ checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" [[package]] name = "nom" -version = "5.1.2" +version = "6.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffb4262d26ed83a1c0a33a38fe2bb15797329c85770da05e6b828ddb782627af" +checksum = "e7413f999671bd4745a7b624bd370a569fb6bc574b23c83a3c5ed2e453f3d5e2" dependencies = [ + "bitvec", + "funty", + "lexical-core", "memchr", "version_check", ] @@ -273,15 +329,15 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.4.1" +version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "260e51e7efe62b592207e9e13a68e43692a7a279171d6ba57abd208bf23645ad" +checksum = "af8b08b04175473088b46763e51ee54da5f9a164bc162f615b91bc179dbf15a3" [[package]] name = "ordered-float" -version = "2.0.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fe9037165d7023b1228bc4ae9a2fa1a2b0095eca6c2998c624723dfd01314a5" +checksum = "766f840da25490628d8e63e529cd21c014f6600c6b8517add12a6fa6167a6218" dependencies = [ "num-traits", ] @@ -300,9 +356,9 @@ checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" [[package]] name = "predicates" -version = "1.0.5" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96bfead12e90dccead362d62bb2c90a5f6fc4584963645bc7f71a735e0b0735a" +checksum = "eeb433456c1a57cc93554dea3ce40b4c19c4057e41c55d4a0f3d84ea71c325aa" dependencies = [ "difference", "predicates-core", @@ -310,15 +366,15 @@ dependencies = [ [[package]] name = "predicates-core" -version = "1.0.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06075c3a3e92559ff8929e7a280684489ea27fe44805174c3ebd9328dcb37178" +checksum = "57e35a3326b75e49aa85f5dc6ec15b41108cf5aee58eabb1f274dd18b73c2451" [[package]] name = "predicates-tree" -version = "1.0.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e63c4859013b38a76eca2414c64911fba30def9e3202ac461a2d22831220124" +checksum = "15f553275e5721409451eb85e15fd9a860a6e5ab4496eb215987502b5f5391f2" dependencies = [ "predicates-core", "treeline", @@ -359,24 +415,42 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.7" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" +checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" dependencies = [ "proc-macro2", ] +[[package]] +name = "radium" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "941ba9d78d8e2f7ce474c015eea4d9c6d25b6a3327f9832ee29a4de27f91bbb8" + [[package]] name = "rand" version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" dependencies = [ - "getrandom", + "getrandom 0.1.16", "libc", - "rand_chacha", - "rand_core", - "rand_hc", + "rand_chacha 0.2.2", + "rand_core 0.5.1", + "rand_hc 0.2.0", +] + +[[package]] +name = "rand" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e" +dependencies = [ + "libc", + "rand_chacha 0.3.0", + "rand_core 0.6.2", + "rand_hc 0.3.0", ] [[package]] @@ -386,7 +460,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" dependencies = [ "ppv-lite86", - "rand_core", + "rand_core 0.5.1", +] + +[[package]] +name = "rand_chacha" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.2", ] [[package]] @@ -395,7 +479,16 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" dependencies = [ - "getrandom", + "getrandom 0.1.16", +] + +[[package]] +name = "rand_core" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34cf66eb183df1c5876e2dcf6b13d57340741e8dc255b48e40a26de954d06ae7" +dependencies = [ + "getrandom 0.2.2", ] [[package]] @@ -404,25 +497,46 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" dependencies = [ - "rand_core", + "rand_core 0.5.1", +] + +[[package]] +name = "rand_hc" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73" +dependencies = [ + "rand_core 0.6.2", ] [[package]] name = "redox_syscall" -version = "0.1.57" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" +checksum = "94341e4e44e24f6b591b59e47a8a027df12e008d73fd5672dbea9cc22f4507d9" +dependencies = [ + "bitflags", +] [[package]] name = "redox_users" -version = "0.3.5" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de0737333e7a9502c789a36d7c7fa6092a49895d4faa31ca5df163857ded2e9d" +checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64" dependencies = [ - "getrandom", + "getrandom 0.2.2", "redox_syscall", ] +[[package]] +name = "regex-automata" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae1ded71d66a4a97f5e961fd0cb25a5f366a42a41570d16a763a69c092c26ae4" +dependencies = [ + "byteorder", +] + [[package]] name = "remove_dir_all" version = "0.5.3" @@ -432,6 +546,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "ryu" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" + [[package]] name = "seq-macro" version = "0.2.1" @@ -440,24 +560,30 @@ checksum = "d5b3bd665f328d73d7079123bfbd14a6edd74187667b5c6f340adfc65ea9d25a" [[package]] name = "serde" -version = "1.0.117" +version = "1.0.125" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b88fa983de7720629c9387e9f517353ed404164b1e482c970a90c1a4aaf7dc1a" +checksum = "558dc50e1a5a5fa7112ca2ce4effcb321b0300c0d4ccf0776a9f60cd89031171" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.117" +version = "1.0.125" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbd1ae72adb44aab48f325a02444a5fc079349a8d804c1fc922aed3f7454c74e" +checksum = "b093b7a2bb58203b5da3056c05b4ec1fed827dcfdb37347a8841695263b3d06d" dependencies = [ "proc-macro2", "quote", "syn", ] +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + [[package]] name = "strsim" version = "0.10.0" @@ -466,9 +592,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "syn" -version = "1.0.48" +version = "1.0.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc371affeffc477f42a221a1e4297aedcea33d47d19b61455588bd9d8f6b19ac" +checksum = "6498a9efc342871f91cc2d0d694c674368b4ceb40f62b65a7a08c3792935e702" dependencies = [ "proc-macro2", "quote", @@ -476,14 +602,20 @@ dependencies = [ ] [[package]] -name = "tempfile" -version = "3.1.0" +name = "tap" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + +[[package]] +name = "tempfile" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" dependencies = [ - "cfg-if 0.1.10", + "cfg-if", "libc", - "rand", + "rand 0.8.3", "redox_syscall", "remove_dir_all", "winapi", @@ -491,9 +623,9 @@ dependencies = [ [[package]] name = "termcolor" -version = "1.1.0" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb6bfa289a4d7c5766392812c0a1f4c1ba45afa1ad47803c11e1f407d846d75f" +checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4" dependencies = [ "winapi-util", ] @@ -515,9 +647,9 @@ checksum = "a7f741b240f1a48843f9b8e0444fb55fb2a4ff67293b50a9179dfd5ea67f8d41" [[package]] name = "unicode-segmentation" -version = "1.6.0" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0" +checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796" [[package]] name = "unicode-width" @@ -539,9 +671,9 @@ checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" [[package]] name = "version_check" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" +checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" [[package]] name = "wait-timeout" @@ -558,6 +690,12 @@ version = "0.9.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" +[[package]] +name = "wasi" +version = "0.10.2+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" + [[package]] name = "winapi" version = "0.3.9" @@ -589,6 +727,12 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "wyz" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214" + [[package]] name = "zoxide" version = "0.5.0" @@ -603,7 +747,7 @@ dependencies = [ "glob", "once_cell", "ordered-float", - "rand", + "rand 0.7.3", "seq-macro", "serde", "tempfile", diff --git a/Cargo.toml b/Cargo.toml index 7604b9d..c9d655b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,12 +2,12 @@ name = "zoxide" version = "0.5.0" authors = ["Ajeet D'Souza <98ajeet@gmail.com>"] +edition = "2018" description = "A faster way to navigate your filesystem" repository = "https://github.com/ajeetdsouza/zoxide/" -edition = "2018" +license = "MIT" keywords = ["cli"] categories = ["command-line-utilities", "filesystem"] -license = "MIT" [dependencies] anyhow = "1.0.32" @@ -25,10 +25,30 @@ tempfile = "3.1.0" [target.'cfg(windows)'.dependencies] rand = "0.7.3" -[target.'cfg(unix)'.dev-dependencies] +[dev-dependencies] assert_cmd = "1.0.1" seq-macro = "0.2.1" +[features] +default = [] +# Adds tests for code generated by `zoxide init`. +# This requires the following external programs available in $PATH: +# - bash +# - black: +# - dash +# - fish: +# - mypy: +# - nushell: +# - powershell: +# - pylint: +# - shellcheck: +# - shfmt: +# - xonsh: +# - zsh: +# Since most users are unlikely to have installed all of the above, these tests +# are disabled by default. +shell_tests = [] + [profile.release] codegen-units = 1 lto = true diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..eaa5007 --- /dev/null +++ b/Makefile @@ -0,0 +1,63 @@ +ifeq ($(CI), true) + ci_color_always := --color=always +endif + +ifeq ($(RELEASE), true) + build_flags := --release +endif + +ifeq ($(OS), Windows_NT) + NIX := false +else + NIX := true +endif + +.PHONY: build clean install test uninstall + +ifeq ($(NIX), true) +build: + nix-shell --pure --run 'cargo build $(build_flags) $(ci_color_always)' +else +build: + cargo build $(build_flags) $(ci_color_always) +endif + +ifeq ($(NIX), true) +clean: + nix-shell --pure --run 'cargo clean $(ci_color_always)' +else +clean: + cargo clean $(ci_color_always) +endif + +ifeq ($(NIX), true) +install: + nix-shell --pure --run 'cargo install --path=. $(ci_color_always)' +else +install: + cargo install --path=. $(ci_color_always) +endif + +ifeq ($(NIX), true) +test: + nix-shell --pure --run 'cargo fmt -- --check --files-with-diff $(ci_color_always)' + nix-shell --pure --run 'cargo check --all-features $(ci_color_always)' + nix-shell --pure --run 'cargo clippy --all-features $(ci_color_always) -- --deny warnings --deny clippy::all' + nix-shell --pure --run 'cargo test --all-features --no-fail-fast $(ci_color_always)' + nix-shell --pure --run 'cargo audit --deny warnings $(ci_color_always) --ignore=RUSTSEC-2020-0095' +else +test: + cargo fmt -- --check --files-with-diff $(ci_color_always) + cargo check --all-features $(ci_color_always) + cargo clippy --all-features $(ci_color_always) -- --deny warnings --deny clippy::all + cargo test --no-fail-fast $(ci_color_always) + cargo audit --deny warnings $(ci_color_always) --ignore=RUSTSEC-2020-0095 +endif + +ifeq ($(NIX), true) +uninstall: + nix-shell --pure --run 'cargo uninstall $(ci_color_always)' +else +uninstall: + cargo uninstall $(ci_color_always) +endif diff --git a/shell.nix b/shell.nix index 17aa560..e6e11a2 100644 --- a/shell.nix +++ b/shell.nix @@ -1,32 +1,26 @@ { pkgs ? import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/20.09.tar.gz") {} }: let - my-python3-pkgs = python3-pkgs: with python3-pkgs; [ - black - mypy - pylint - ]; - my-python3 = pkgs.python3.withPackages my-python3-pkgs; + python-pkgs = pkgs.python3.withPackages (pkgs: [ pkgs.black pkgs.mypy pkgs.pylint ]); in pkgs.mkShell { name = "env"; - nativeBuildInputs = [ - pkgs.rustc - pkgs.cargo - ]; buildInputs = [ pkgs.bash + pkgs.cargo + pkgs.cargo-audit pkgs.dash pkgs.fish pkgs.fzf pkgs.git pkgs.powershell + pkgs.rustc pkgs.shellcheck pkgs.shfmt pkgs.xonsh pkgs.zsh - my-python3 + python-pkgs ]; # Set Environment Variables diff --git a/src/db/dir.rs b/src/db/dir.rs index b869a3c..73ed2cd 100644 --- a/src/db/dir.rs +++ b/src/db/dir.rs @@ -153,7 +153,7 @@ impl Display for DirDisplayScore<'_> { let score = if score > 9999.0 { 9999 } else if score > 0.0 { - score as _ + score as u32 } else { 0 }; @@ -163,3 +163,26 @@ impl Display for DirDisplayScore<'_> { pub type Rank = f64; pub type Epoch = u64; + +#[cfg(test)] +mod tests { + use super::{Dir, DirList}; + + use std::borrow::Cow; + + #[test] + fn zero_copy() { + let dirs = DirList(vec![Dir { + path: "/".into(), + rank: 0.0, + last_accessed: 0, + }]); + + let bytes = dirs.to_bytes().unwrap(); + let dirs = DirList::from_bytes(&bytes).unwrap(); + + for dir in dirs.iter() { + assert!(matches!(dir.path, Cow::Borrowed(_))) + } + } +} diff --git a/src/db/mod.rs b/src/db/mod.rs index dcd6091..d53a4f0 100644 --- a/src/db/mod.rs +++ b/src/db/mod.rs @@ -53,9 +53,9 @@ impl<'a> Database<'a> { Ok(()) } + /// Adds a new directory or increments its rank. Also updates its last accessed time. pub fn add>(&mut self, path: S, now: Epoch) { let path = path.as_ref(); - debug_assert!(Path::new(path).is_absolute()); match self.dirs.iter_mut().find(|dir| dir.path == path) { None => self.dirs.push(Dir { @@ -85,6 +85,8 @@ impl<'a> Database<'a> { .filter(move |dir| dir.is_match(&query, resolve_symlinks)) } + /// Removes the directory with `path` from the store. + /// This does not preserve ordering, but is O(1). pub fn remove>(&mut self, path: S) -> bool { let path = path.as_ref(); diff --git a/src/import/autojump.rs b/src/import/autojump.rs index ae03bf6..f5e31cf 100644 --- a/src/import/autojump.rs +++ b/src/import/autojump.rs @@ -43,9 +43,11 @@ impl Import for Autojump { .with_context(|| format!("line {}: error reading from autojump database", idx + 1))?; } + // Don't import actual ranks from autojump, since its algorithm is + // very different, and might take a while to get normalized. let rank_sum = entries.iter().map(|(_, rank)| rank).sum::(); for &(path, rank) in entries.iter() { - if db.dirs.iter_mut().find(|dir| dir.path == path).is_none() { + if !db.dirs.iter().any(|dir| dir.path == path) { db.dirs.push(Dir { path: Cow::Owned(path.into()), rank: rank / rank_sum, diff --git a/src/shell.rs b/src/shell.rs index 0636187..56f087d 100644 --- a/src/shell.rs +++ b/src/shell.rs @@ -37,7 +37,7 @@ pub enum Hook { Pwd, } -#[cfg(unix)] +#[cfg(feature = "shell_tests")] #[cfg(test)] mod tests { use super::*;