mirror of
https://github.com/bootandy/dust.git
synced 2025-12-07 05:10:40 -08:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6404b79c00 | ||
|
|
143fc458b4 |
297
.github/workflows/CICD.yml
vendored
297
.github/workflows/CICD.yml
vendored
@@ -1,297 +0,0 @@
|
||||
name: CICD
|
||||
|
||||
# spell-checker:ignore CICD CODECOV MSVC MacOS Peltoche SHAs buildable clippy esac fakeroot gnueabihf halium libssl mkdir musl popd printf pushd rustfmt softprops toolchain
|
||||
|
||||
env:
|
||||
PROJECT_NAME: dust
|
||||
PROJECT_DESC: "du + rust = dust"
|
||||
PROJECT_AUTH: "bootandy"
|
||||
RUST_MIN_SRV: "1.31.0"
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
style:
|
||||
name: Style
|
||||
runs-on: ${{ matrix.job.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
job:
|
||||
- { os: ubuntu-latest }
|
||||
- { os: macos-latest }
|
||||
- { os: windows-latest }
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Initialize workflow variables
|
||||
id: vars
|
||||
shell: bash
|
||||
run: |
|
||||
# 'windows-latest' `cargo fmt` is bugged for this project (see reasons @ GH:rust-lang/rustfmt #3324, #3590, #3688 ; waiting for repair)
|
||||
JOB_DO_FORMAT_TESTING="true"
|
||||
case ${{ matrix.job.os }} in windows-latest) unset JOB_DO_FORMAT_TESTING ;; esac;
|
||||
echo set-output name=JOB_DO_FORMAT_TESTING::${JOB_DO_FORMAT_TESTING:-<empty>/false}
|
||||
echo ::set-output name=JOB_DO_FORMAT_TESTING::${JOB_DO_FORMAT_TESTING}
|
||||
# target-specific options
|
||||
# * CARGO_FEATURES_OPTION
|
||||
CARGO_FEATURES_OPTION='' ;
|
||||
if [ -n "${{ matrix.job.features }}" ]; then CARGO_FEATURES_OPTION='--features "${{ matrix.job.features }}"' ; fi
|
||||
echo set-output name=CARGO_FEATURES_OPTION::${CARGO_FEATURES_OPTION}
|
||||
echo ::set-output name=CARGO_FEATURES_OPTION::${CARGO_FEATURES_OPTION}
|
||||
- name: Install `rust` toolchain
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
override: true
|
||||
profile: minimal # minimal component installation (ie, no documentation)
|
||||
components: rustfmt, clippy
|
||||
- name: "`fmt` testing"
|
||||
if: steps.vars.outputs.JOB_DO_FORMAT_TESTING
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: fmt
|
||||
args: --all -- --check
|
||||
- name: "`clippy` testing"
|
||||
if: success() || failure() # run regardless of prior step ("`fmt` testing") success/failure
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: clippy
|
||||
args: ${{ matrix.job.cargo-options }} ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }} -- -D warnings
|
||||
|
||||
min_version:
|
||||
name: MinSRV # Minimum supported rust version
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Install `rust` toolchain (v${{ env.RUST_MIN_SRV }})
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: ${{ env.RUST_MIN_SRV }}
|
||||
profile: minimal # minimal component installation (ie, no documentation)
|
||||
- name: Test
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: test
|
||||
|
||||
build:
|
||||
name: Build
|
||||
runs-on: ${{ matrix.job.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
job:
|
||||
# { os, target, cargo-options, features, use-cross, toolchain }
|
||||
- { os: ubuntu-latest , target: arm-unknown-linux-gnueabihf , use-cross: use-cross }
|
||||
- { os: ubuntu-18.04 , target: i686-unknown-linux-gnu , use-cross: use-cross }
|
||||
- { os: ubuntu-18.04 , target: i686-unknown-linux-musl , use-cross: use-cross }
|
||||
- { os: ubuntu-18.04 , target: x86_64-unknown-linux-gnu , use-cross: use-cross }
|
||||
- { os: ubuntu-18.04 , target: x86_64-unknown-linux-musl , use-cross: use-cross }
|
||||
- { os: ubuntu-16.04 , target: x86_64-unknown-linux-gnu , use-cross: use-cross }
|
||||
- { os: macos-latest , target: x86_64-apple-darwin }
|
||||
- { os: windows-latest , target: i686-pc-windows-gnu }
|
||||
- { os: windows-latest , target: i686-pc-windows-msvc }
|
||||
- { os: windows-latest , target: x86_64-pc-windows-gnu } ## !maint: [rivy; 2020-01-21] may break due to rust bug; follow possible solution from GH:rust-lang/rust#47048 (refs: GH:rust-lang/rust#47048 , GH:rust-lang/rust#53454 , GH:bike-barn/hermit#172 )
|
||||
- { os: windows-latest , target: x86_64-pc-windows-msvc }
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Install any prerequisites
|
||||
shell: bash
|
||||
run: |
|
||||
case ${{ matrix.job.target }} in
|
||||
arm-unknown-linux-gnueabihf) sudo apt-get -y update ; sudo apt-get -y install gcc-arm-linux-gnueabihf ;;
|
||||
esac
|
||||
- name: Initialize workflow variables
|
||||
id: vars
|
||||
shell: bash
|
||||
run: |
|
||||
# toolchain
|
||||
TOOLCHAIN="stable" ## default to "stable" toolchain
|
||||
# * specify alternate TOOLCHAIN for *-pc-windows-gnu targets; gnu targets on Windows are broken for the standard *-pc-windows-msvc toolchain (refs: <https://github.com/rust-lang/rust/issues/47048>, <https://github.com/rust-lang/rust/issues/53454>, <https://github.com/rust-lang/cargo/issues/6754>)
|
||||
case ${{ matrix.job.target }} in *-pc-windows-gnu) TOOLCHAIN="stable-${{ matrix.job.target }}" ;; esac;
|
||||
# * use requested TOOLCHAIN if specified
|
||||
if [ -n "${{ matrix.job.toolchain }}" ]; then TOOLCHAIN="${{ matrix.job.toolchain }}" ; fi
|
||||
echo set-output name=TOOLCHAIN::${TOOLCHAIN}
|
||||
echo ::set-output name=TOOLCHAIN::${TOOLCHAIN}
|
||||
# staging directory
|
||||
STAGING='_staging'
|
||||
echo set-output name=STAGING::${STAGING}
|
||||
echo ::set-output name=STAGING::${STAGING}
|
||||
# determine EXE suffix
|
||||
EXE_suffix="" ; case ${{ matrix.job.target }} in *-pc-windows-*) EXE_suffix=".exe" ;; esac;
|
||||
echo set-output name=EXE_suffix::${EXE_suffix}
|
||||
echo ::set-output name=EXE_suffix::${EXE_suffix}
|
||||
# parse commit reference info
|
||||
REF_NAME=${GITHUB_REF#refs/*/}
|
||||
unset REF_BRANCH ; case ${GITHUB_REF} in refs/heads/*) REF_BRANCH=${GITHUB_REF#refs/heads/} ;; esac;
|
||||
unset REF_TAG ; case ${GITHUB_REF} in refs/tags/*) REF_TAG=${GITHUB_REF#refs/tags/} ;; esac;
|
||||
REF_SHAS=${GITHUB_SHA:0:8}
|
||||
echo set-output name=REF_NAME::${REF_NAME}
|
||||
echo set-output name=REF_BRANCH::${REF_BRANCH}
|
||||
echo set-output name=REF_TAG::${REF_TAG}
|
||||
echo set-output name=REF_SHAS::${REF_SHAS}
|
||||
echo ::set-output name=REF_NAME::${REF_NAME}
|
||||
echo ::set-output name=REF_BRANCH::${REF_BRANCH}
|
||||
echo ::set-output name=REF_TAG::${REF_TAG}
|
||||
echo ::set-output name=REF_SHAS::${REF_SHAS}
|
||||
# parse target
|
||||
unset TARGET_ARCH ; case ${{ matrix.job.target }} in arm-unknown-linux-gnueabihf) TARGET_ARCH=arm ;; i686-*) TARGET_ARCH=i686 ;; x86_64-*) TARGET_ARCH=x86_64 ;; esac;
|
||||
echo set-output name=TARGET_ARCH::${TARGET_ARCH}
|
||||
echo ::set-output name=TARGET_ARCH::${TARGET_ARCH}
|
||||
unset TARGET_OS ; case ${{ matrix.job.target }} in *-linux-*) TARGET_OS=linux ;; *-apple-*) TARGET_OS=macos ;; *-windows-*) TARGET_OS=windows ;; esac;
|
||||
echo set-output name=TARGET_OS::${TARGET_OS}
|
||||
echo ::set-output name=TARGET_OS::${TARGET_OS}
|
||||
# package name
|
||||
PKG_suffix=".tar.gz" ; case ${{ matrix.job.target }} in *-pc-windows-*) PKG_suffix=".zip" ;; esac;
|
||||
PKG_BASENAME=${PROJECT_NAME}-${REF_TAG:-$REF_SHAS}-${{ matrix.job.target }}
|
||||
PKG_NAME=${PKG_BASENAME}${PKG_suffix}
|
||||
echo set-output name=PKG_suffix::${PKG_suffix}
|
||||
echo set-output name=PKG_BASENAME::${PKG_BASENAME}
|
||||
echo set-output name=PKG_NAME::${PKG_NAME}
|
||||
echo ::set-output name=PKG_suffix::${PKG_suffix}
|
||||
echo ::set-output name=PKG_BASENAME::${PKG_BASENAME}
|
||||
echo ::set-output name=PKG_NAME::${PKG_NAME}
|
||||
# deployable tag? (ie, leading "vM" or "M"; M == version number)
|
||||
unset DEPLOY ; if [[ $REF_TAG =~ ^[vV]?[0-9].* ]]; then DEPLOY='true' ; fi
|
||||
echo set-output name=DEPLOY::${DEPLOY:-<empty>/false}
|
||||
echo ::set-output name=DEPLOY::${DEPLOY}
|
||||
# target-specific options
|
||||
# * CARGO_FEATURES_OPTION
|
||||
CARGO_FEATURES_OPTION='' ;
|
||||
if [ -n "${{ matrix.job.features }}" ]; then CARGO_FEATURES_OPTION='--features "${{ matrix.job.features }}"' ; fi
|
||||
echo set-output name=CARGO_FEATURES_OPTION::${CARGO_FEATURES_OPTION}
|
||||
echo ::set-output name=CARGO_FEATURES_OPTION::${CARGO_FEATURES_OPTION}
|
||||
# * CARGO_USE_CROSS (truthy)
|
||||
CARGO_USE_CROSS='true' ; case '${{ matrix.job.use-cross }}' in ''|0|f|false|n|no) unset CARGO_USE_CROSS ;; esac;
|
||||
echo set-output name=CARGO_USE_CROSS::${CARGO_USE_CROSS:-<empty>/false}
|
||||
echo ::set-output name=CARGO_USE_CROSS::${CARGO_USE_CROSS}
|
||||
# # * `arm` cannot be tested on ubuntu-* hosts (b/c testing is currently primarily done via comparison of target outputs with built-in outputs and the `arm` target is not executable on the host)
|
||||
JOB_DO_TESTING="true"
|
||||
case ${{ matrix.job.target }} in arm-*) unset JOB_DO_TESTING ;; esac;
|
||||
echo set-output name=JOB_DO_TESTING::${JOB_DO_TESTING:-<empty>/false}
|
||||
echo ::set-output name=JOB_DO_TESTING::${JOB_DO_TESTING}
|
||||
# # * test only binary for arm-type targets
|
||||
unset CARGO_TEST_OPTIONS
|
||||
unset CARGO_TEST_OPTIONS ; case ${{ matrix.job.target }} in arm-*) CARGO_TEST_OPTIONS="--bin ${PROJECT_NAME}" ;; esac;
|
||||
echo set-output name=CARGO_TEST_OPTIONS::${CARGO_TEST_OPTIONS}
|
||||
echo ::set-output name=CARGO_TEST_OPTIONS::${CARGO_TEST_OPTIONS}
|
||||
# * strip executable?
|
||||
STRIP="strip" ; case ${{ matrix.job.target }} in arm-unknown-linux-gnueabihf) STRIP="arm-linux-gnueabihf-strip" ;; *-pc-windows-msvc) STRIP="" ;; esac;
|
||||
echo set-output name=STRIP::${STRIP}
|
||||
echo ::set-output name=STRIP::${STRIP}
|
||||
- name: Create all needed build/work directories
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir -p '${{ steps.vars.outputs.STAGING }}'
|
||||
mkdir -p '${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_BASENAME }}'
|
||||
- name: rust toolchain ~ install
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: ${{ steps.vars.outputs.TOOLCHAIN }}
|
||||
target: ${{ matrix.job.target }}
|
||||
override: true
|
||||
profile: minimal # minimal component installation (ie, no documentation)
|
||||
- name: Info
|
||||
shell: bash
|
||||
run: |
|
||||
gcc --version || true
|
||||
rustup -V
|
||||
rustup toolchain list
|
||||
rustup default
|
||||
cargo -V
|
||||
rustc -V
|
||||
- name: Build
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
use-cross: ${{ steps.vars.outputs.CARGO_USE_CROSS }}
|
||||
command: build
|
||||
args: --release --target=${{ matrix.job.target }} ${{ matrix.job.cargo-options }} ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }}
|
||||
- name: Test
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
use-cross: ${{ steps.vars.outputs.CARGO_USE_CROSS }}
|
||||
command: test
|
||||
args: --target=${{ matrix.job.target }} ${{ steps.vars.outputs.CARGO_TEST_OPTIONS}} ${{ matrix.job.cargo-options }} ${{ steps.vars.outputs.CARGO_FEATURES_OPTION }}
|
||||
- name: Archive executable artifacts
|
||||
uses: actions/upload-artifact@master
|
||||
with:
|
||||
name: ${{ env.PROJECT_NAME }}-${{ matrix.job.target }}
|
||||
path: target/${{ matrix.job.target }}/release/${{ env.PROJECT_NAME }}${{ steps.vars.outputs.EXE_suffix }}
|
||||
- name: Package
|
||||
shell: bash
|
||||
run: |
|
||||
# binary
|
||||
cp 'target/${{ matrix.job.target }}/release/${{ env.PROJECT_NAME }}${{ steps.vars.outputs.EXE_suffix }}' '${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_BASENAME }}/'
|
||||
# `strip` binary (if needed)
|
||||
if [ -n "${{ steps.vars.outputs.STRIP }}" ]; then "${{ steps.vars.outputs.STRIP }}" '${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_BASENAME }}/${{ env.PROJECT_NAME }}${{ steps.vars.outputs.EXE_suffix }}' ; fi
|
||||
# README and LICENSE
|
||||
cp README.md '${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_BASENAME }}/'
|
||||
cp LICENSE '${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_BASENAME }}/'
|
||||
# base compressed package
|
||||
pushd '${{ steps.vars.outputs.STAGING }}/' >/dev/null
|
||||
case ${{ matrix.job.target }} in
|
||||
*-pc-windows-*) 7z -y a '${{ steps.vars.outputs.PKG_NAME }}' '${{ steps.vars.outputs.PKG_BASENAME }}'/* | tail -2 ;;
|
||||
*) tar czf '${{ steps.vars.outputs.PKG_NAME }}' '${{ steps.vars.outputs.PKG_BASENAME }}'/* ;;
|
||||
esac;
|
||||
popd >/dev/null
|
||||
- name: Publish
|
||||
uses: softprops/action-gh-release@v1
|
||||
if: steps.vars.outputs.DEPLOY
|
||||
with:
|
||||
files: |
|
||||
${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_NAME }}
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
## fix! [rivy; 2020-22-01] `cargo tarpaulin` is unable to test this repo at the moment; alternate recipe or another testing framework?
|
||||
# coverage:
|
||||
# name: Code Coverage
|
||||
# runs-on: ${{ matrix.job.os }}
|
||||
# strategy:
|
||||
# fail-fast: true
|
||||
# matrix:
|
||||
# # job: [ { os: ubuntu-latest }, { os: macos-latest }, { os: windows-latest } ]
|
||||
# job: [ { os: ubuntu-latest } ] ## cargo-tarpaulin is currently only available on linux
|
||||
# steps:
|
||||
# - uses: actions/checkout@v1
|
||||
# # - name: Reattach HEAD ## may be needed for accurate code coverage info
|
||||
# # run: git checkout ${{ github.head_ref }}
|
||||
# - name: Initialize workflow variables
|
||||
# id: vars
|
||||
# shell: bash
|
||||
# run: |
|
||||
# # staging directory
|
||||
# STAGING='_staging'
|
||||
# echo set-output name=STAGING::${STAGING}
|
||||
# echo ::set-output name=STAGING::${STAGING}
|
||||
# # check for CODECOV_TOKEN availability (work-around for inaccessible 'secrets' object for 'if'; see <https://github.community/t5/GitHub-Actions/jobs-lt-job-id-gt-if-does-not-work-with-env-secrets/m-p/38549>)
|
||||
# unset HAS_CODECOV_TOKEN
|
||||
# if [ -n $CODECOV_TOKEN ]; then HAS_CODECOV_TOKEN='true' ; fi
|
||||
# echo set-output name=HAS_CODECOV_TOKEN::${HAS_CODECOV_TOKEN}
|
||||
# echo ::set-output name=HAS_CODECOV_TOKEN::${HAS_CODECOV_TOKEN}
|
||||
# env:
|
||||
# CODECOV_TOKEN: "${{ secrets.CODECOV_TOKEN }}"
|
||||
# - name: Create all needed build/work directories
|
||||
# shell: bash
|
||||
# run: |
|
||||
# mkdir -p '${{ steps.vars.outputs.STAGING }}/work'
|
||||
# - name: Install required packages
|
||||
# run: |
|
||||
# sudo apt-get -y install libssl-dev
|
||||
# pushd '${{ steps.vars.outputs.STAGING }}/work' >/dev/null
|
||||
# wget --no-verbose https://github.com/xd009642/tarpaulin/releases/download/0.9.3/cargo-tarpaulin-0.9.3-travis.tar.gz
|
||||
# tar xf cargo-tarpaulin-0.9.3-travis.tar.gz
|
||||
# cp cargo-tarpaulin "$(dirname -- "$(which cargo)")"/
|
||||
# popd >/dev/null
|
||||
# - name: Generate coverage
|
||||
# run: |
|
||||
# cargo tarpaulin --out Xml
|
||||
# - name: Upload coverage results (CodeCov.io)
|
||||
# # CODECOV_TOKEN (aka, "Repository Upload Token" for REPO from CodeCov.io) ## set via REPO/Settings/Secrets
|
||||
# # if: secrets.CODECOV_TOKEN (not supported {yet?}; see <https://github.community/t5/GitHub-Actions/jobs-lt-job-id-gt-if-does-not-work-with-env-secrets/m-p/38549>)
|
||||
# if: steps.vars.outputs.HAS_CODECOV_TOKEN
|
||||
# run: |
|
||||
# # CodeCov.io
|
||||
# cargo tarpaulin --out Xml
|
||||
# bash <(curl -s https://codecov.io/bash)
|
||||
# env:
|
||||
# CODECOV_TOKEN: "${{ secrets.CODECOV_TOKEN }}"
|
||||
6
.gitignore
vendored
6
.gitignore
vendored
@@ -2,8 +2,10 @@
|
||||
# will have compiled files and executables
|
||||
/target/
|
||||
|
||||
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
|
||||
# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock
|
||||
Cargo.lock
|
||||
|
||||
# These are backup files generated by rustfmt
|
||||
**/*.rs.bk
|
||||
*.swp
|
||||
.vscode/*
|
||||
*.idea/*
|
||||
42
.travis.yml
Normal file
42
.travis.yml
Normal file
@@ -0,0 +1,42 @@
|
||||
|
||||
env:
|
||||
global:
|
||||
- PROJECT_NAME=dust
|
||||
- CHANNEL=stable
|
||||
|
||||
language: rust
|
||||
rust:
|
||||
- stable
|
||||
matrix:
|
||||
fast_finish: true
|
||||
- os: osx
|
||||
env: TARGET=i686-apple-darwin
|
||||
- os: linux
|
||||
env: TARGET=i686-unknown-linux-gnu
|
||||
- os: osx
|
||||
env: TARGET=x86_64-apple-darwin
|
||||
- os: linux
|
||||
env: TARGET=x86_64-unknown-linux-gnu
|
||||
cache: cargo
|
||||
|
||||
before_install:
|
||||
- export PATH="$PATH:$HOME/.cargo/bin"
|
||||
|
||||
script:
|
||||
- cargo build --release --target $TARGET
|
||||
- cargo test --target $TARGET
|
||||
|
||||
deploy:
|
||||
provider: releases
|
||||
api_key:
|
||||
secure: "osa6xr6VGDSKUFGPVSElFl2ItJQ0vzTuc+xcBYtEO663sFf5bsCXnBmzdNB4dSfiV1KdVXZQaN7S2rIO9GoWVY02hz8OLYWh5wDXkdQQ8hSEl9FXnSB8I1zWTB4dYsnAZPkjbkH4p+HmmlH6COH1FRKWcEtJMWbZBr0kVc3hxWQue2U5Lo0FhWgNo9oOfs8b6lvF9N/bSQaaeE0OEBVyc3iOBG+03UrcPwhuO3vUNYPkiqxdwGctYyjBEbc4OTKLPazvgFaDmiACtIM1iPIly5WXR+A/3hMxgDKlpqi9F8bO/I8C+kXpP7ZBlqkejo8MwjZ8UHXzX7uXsq/5Upp8tPDTr0ko4dDvDrQMu+mnGwsEU3T8HPGE2c1DZl858tMt/NhUjtEXJDY5Fadia3I7Th5dUGR8O3ylnXf8rkSxFcqDAJ6u9KFH2SUAR5nEU4hRSSx8KjSTadQsQGQS6Iyvf8HV0GwPPkJStEZq/ZHE1hEQHXZBREBHnjgCkjj/LItyFFMs0qZbfTUBurKokQnQElkOddpzLsfb6G6+8rV6+WNmsuqUVx04YKTfjb5X/tV0Bjgx1YOMMBhWXrRi+XO04l9fsoU8zYfb29bqEzC7Rx38/A4Bncp/eI1JqUxv7EIbpEadIVq1LrVJg54O7Kx0LA6AsCRwTdmFGdSFbz3oujI="
|
||||
file: ${PROJECT_NAME}-${TRAVIS_TAG}-${TARGET}.tar.gz
|
||||
skip_cleanup: true
|
||||
on:
|
||||
repo: bootandy/dust
|
||||
tags: true
|
||||
|
||||
notifications:
|
||||
email:
|
||||
on_success: never
|
||||
|
||||
576
Cargo.lock
generated
576
Cargo.lock
generated
@@ -1,576 +0,0 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
version = "0.7.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ansi_term"
|
||||
version = "0.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ansi_term"
|
||||
version = "0.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "assert_cmd"
|
||||
version = "0.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"doc-comment 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"escargot 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"predicates 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"predicates-core 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"predicates-tree 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "atty"
|
||||
version = "0.2.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"hermit-abi 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.68 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "bstr"
|
||||
version = "0.2.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "0.1.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "2.33.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-channel"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-utils"
|
||||
version = "0.7.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"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]]
|
||||
name = "difference"
|
||||
version = "2.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "doc-comment"
|
||||
version = "0.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "du-dust"
|
||||
version = "0.5.2"
|
||||
dependencies = [
|
||||
"ansi_term 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"assert_cmd 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"crossbeam-channel 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ignore 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lscolors 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num_cpus 1.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"terminal_size 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"walkdir 2.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "escargot"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.105 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_json 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fnv"
|
||||
version = "1.0.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.1.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.68 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasi 0.9.0+wasi-snapshot-preview1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "globset"
|
||||
version = "0.4.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"aho-corasick 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bstr 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 1.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.1.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"libc 0.2.68 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ignore"
|
||||
version = "0.4.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"crossbeam-channel 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"globset 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 1.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"same-file 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"thread_local 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"walkdir 2.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "0.4.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.68"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lscolors"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"ansi_term 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "maybe-uninit"
|
||||
version = "2.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "num_cpus"
|
||||
version = "1.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"hermit-abi 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.68 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ppv-lite86"
|
||||
version = "0.2.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "predicates"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"predicates-core 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "predicates-core"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "predicates-tree"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"predicates-core 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"treeline 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.7.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"getrandom 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.68 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand_chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_chacha"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"ppv-lite86 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"getrandom 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_hc"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.1.56"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.3.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"aho-corasick 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex-syntax 0.6.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"thread_local 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.6.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "remove_dir_all"
|
||||
version = "0.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ryu"
|
||||
version = "1.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "same-file"
|
||||
version = "1.0.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"winapi-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.105"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"serde_derive 1.0.105 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.105"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syn 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.48"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"itoa 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ryu 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.105 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tempfile"
|
||||
version = "3.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.68 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "terminal_size"
|
||||
version = "0.1.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"libc 0.2.68 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "textwrap"
|
||||
version = "0.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thread_local"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "treeline"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-width"
|
||||
version = "0.1.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-xid"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "vec_map"
|
||||
version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "walkdir"
|
||||
version = "2.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"same-file 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.9.0+wasi-snapshot-preview1"
|
||||
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"
|
||||
dependencies = [
|
||||
"winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-i686-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-util"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[metadata]
|
||||
"checksum aho-corasick 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)" = "8716408b8bc624ed7f65d223ddb9ac2d044c0547b6fa4b0d554f3a9540496ada"
|
||||
"checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
|
||||
"checksum ansi_term 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
|
||||
"checksum assert_cmd 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6283bac8dd7226470d491bc4737816fea4ca1fba7a2847f2e9097fd6bfb4624c"
|
||||
"checksum atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
|
||||
"checksum autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d"
|
||||
"checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
|
||||
"checksum bstr 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)" = "2889e6d50f394968c8bf4240dc3f2a7eb4680844d27308f798229ac9d4725f41"
|
||||
"checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
|
||||
"checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9"
|
||||
"checksum crossbeam-channel 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "cced8691919c02aac3cb0a1bc2e9b73d89e832bf9a06fc579d4e71b68a2da061"
|
||||
"checksum crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8"
|
||||
"checksum difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198"
|
||||
"checksum doc-comment 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10"
|
||||
"checksum escargot 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "74cf96bec282dcdb07099f7e31d9fed323bca9435a09aba7b6d99b7617bca96d"
|
||||
"checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3"
|
||||
"checksum getrandom 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb"
|
||||
"checksum globset 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "7ad1da430bd7281dde2576f44c84cc3f0f7b475e7202cd503042dff01a8c8120"
|
||||
"checksum hermit-abi 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "1010591b26bbfe835e9faeabeb11866061cc7dcebffd56ad7d0942d0e61aefd8"
|
||||
"checksum ignore 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "7c81b30e645a7b49ad57340fd900717e6b3404bfe8322035ef189d434c412aa1"
|
||||
"checksum itoa 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "b8b7a7c0c47db5545ed3fef7468ee7bb5b74691498139e4b3f6a20685dc6dd8e"
|
||||
"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||
"checksum libc 0.2.68 (registry+https://github.com/rust-lang/crates.io-index)" = "dea0c0405123bba743ee3f91f49b1c7cfb684eef0da0a50110f758ccf24cdff0"
|
||||
"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7"
|
||||
"checksum lscolors 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ea3b3414b2d015c4fd689815f2551797f3c2296bb241dd709c7da233ec7cba4b"
|
||||
"checksum maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00"
|
||||
"checksum memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400"
|
||||
"checksum num_cpus 1.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "46203554f085ff89c235cd12f7075f3233af9b11ed7c9e16dfe2560d03313ce6"
|
||||
"checksum ppv-lite86 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b"
|
||||
"checksum predicates 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "347a1b6f0b21e636bc9872fb60b83b8e185f6f5516298b8238699f7f9a531030"
|
||||
"checksum predicates-core 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "06075c3a3e92559ff8929e7a280684489ea27fe44805174c3ebd9328dcb37178"
|
||||
"checksum predicates-tree 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8e63c4859013b38a76eca2414c64911fba30def9e3202ac461a2d22831220124"
|
||||
"checksum proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "6c09721c6781493a2a492a96b5a5bf19b65917fe6728884e7c44dd0c60ca3435"
|
||||
"checksum quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2bdc6c187c65bca4260c9011c9e3132efe4909da44726bad24cf7572ae338d7f"
|
||||
"checksum rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03"
|
||||
"checksum rand_chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402"
|
||||
"checksum rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"
|
||||
"checksum rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c"
|
||||
"checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84"
|
||||
"checksum regex 1.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "8900ebc1363efa7ea1c399ccc32daed870b4002651e0bed86e72d501ebbe0048"
|
||||
"checksum regex-syntax 0.6.17 (registry+https://github.com/rust-lang/crates.io-index)" = "7fe5bd57d1d7414c6b5ed48563a2c855d995ff777729dcd91c369ec7fea395ae"
|
||||
"checksum remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e"
|
||||
"checksum ryu 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535622e6be132bccd223f4bb2b8ac8d53cda3c7a6394944d3b2b33fb974f9d76"
|
||||
"checksum same-file 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
|
||||
"checksum serde 1.0.105 (registry+https://github.com/rust-lang/crates.io-index)" = "e707fbbf255b8fc8c3b99abb91e7257a622caeb20a9818cbadbeeede4e0932ff"
|
||||
"checksum serde_derive 1.0.105 (registry+https://github.com/rust-lang/crates.io-index)" = "ac5d00fc561ba2724df6758a17de23df5914f20e41cb00f94d5b7ae42fffaff8"
|
||||
"checksum serde_json 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)" = "9371ade75d4c2d6cb154141b9752cf3781ec9c05e0e5cf35060e1e70ee7b9c25"
|
||||
"checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
|
||||
"checksum syn 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)" = "0df0eb663f387145cab623dea85b09c2c5b4b0aef44e945d928e682fce71bb03"
|
||||
"checksum tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9"
|
||||
"checksum terminal_size 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "e25a60e3024df9029a414be05f46318a77c22538861a22170077d0388c0e926e"
|
||||
"checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
|
||||
"checksum thread_local 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14"
|
||||
"checksum treeline 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a7f741b240f1a48843f9b8e0444fb55fb2a4ff67293b50a9179dfd5ea67f8d41"
|
||||
"checksum unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479"
|
||||
"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
|
||||
"checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a"
|
||||
"checksum walkdir 2.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "777182bc735b6424e1a57516d35ed72cb8019d85c8c9bf536dccb3445c1a2f7d"
|
||||
"checksum wasi 0.9.0+wasi-snapshot-preview1 (registry+https://github.com/rust-lang/crates.io-index)" = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
|
||||
"checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6"
|
||||
"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
"checksum winapi-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4ccfbf554c6ad11084fb7517daca16cfdcaccbdadba4fc336f032a8b12c2ad80"
|
||||
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
44
Cargo.toml
44
Cargo.toml
@@ -1,44 +1,8 @@
|
||||
[package]
|
||||
name = "du-dust"
|
||||
description = "A more intuitive version of du"
|
||||
version = "0.5.2"
|
||||
authors = ["bootandy <bootandy@gmail.com>", "nebkor <code@ardent.nebcorp.com>"]
|
||||
edition = "2018"
|
||||
|
||||
documentation = "https://github.com/bootandy/dust"
|
||||
homepage = "https://github.com/bootandy/dust"
|
||||
repository = "https://github.com/bootandy/dust"
|
||||
|
||||
keywords = ["du", "command-line", "disk", "disk-usage"]
|
||||
categories = ["command-line-utilities"]
|
||||
license = "Apache-2.0"
|
||||
|
||||
[badges]
|
||||
travis-ci = {repository = "https://travis-ci.org/bootandy/dust"}
|
||||
|
||||
[[bin]]
|
||||
name = "dust"
|
||||
path = "src/main.rs"
|
||||
version = "0.1.0"
|
||||
authors = ["bootandy <bootandy@gmail.com>"]
|
||||
|
||||
[dependencies]
|
||||
ansi_term = "=0.12"
|
||||
clap = "=2.33"
|
||||
lscolors = "0.6.0"
|
||||
num_cpus = "1.12"
|
||||
terminal_size = "0.1.10"
|
||||
unicode-width = "0.1.7"
|
||||
ignore="0.4.12"
|
||||
crossbeam-channel = "0.4.2"
|
||||
walkdir="2.3"
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
winapi-util = "0.1"
|
||||
|
||||
[dev-dependencies]
|
||||
assert_cmd ="0.12"
|
||||
tempfile = "=3"
|
||||
|
||||
|
||||
[[test]]
|
||||
name = "integration"
|
||||
path = "tests/tests.rs"
|
||||
ansi_term = "0.11"
|
||||
clap = "2.31"
|
||||
|
||||
74
README.md
74
README.md
@@ -1,60 +1,42 @@
|
||||
|
||||
[](https://travis-ci.org/bootandy/dust)
|
||||
|
||||
|
||||
# Dust
|
||||
du + rust = dust. A rust alternative to du
|
||||
|
||||
du + rust = dust. Like du but more intuitive.
|
||||
Unlike du, dust is meant to give you an instant overview of which directories are using disk space without requiring sort or head. Dust does not count file system blocks; it uses file sizes instead. Dust will print a maximum of 1 'Did not have permissions message'.
|
||||
|
||||
# Why
|
||||
|
||||
Because I want an easy way to see where my disk is being used.
|
||||
|
||||
# Demo
|
||||

|
||||
|
||||
## Install
|
||||
|
||||
#### Cargo <a href="https://repology.org/project/dust-du/versions"><img src="https://repology.org/badge/vertical-allrepos/dust-du.svg" alt="Packaging status" align="right"></a>
|
||||
|
||||
* `cargo install du-dust`
|
||||
|
||||
#### 🍺 Homebrew (Mac OS)
|
||||
|
||||
* `brew install dust`
|
||||
|
||||
#### Download
|
||||
|
||||
* Download Linux/Mac binary from [Releases](https://github.com/bootandy/dust/releases)
|
||||
* unzip file: `tar -xvf _downloaded_file.tar.gz`
|
||||
* move file to executable path: `sudo mv dust /usr/local/bin/`
|
||||
|
||||
## Overview
|
||||
|
||||
Dust is meant to give you an instant overview of which directories are using disk space without requiring sort or head. Dust will print a maximum of one 'Did not have permissions message'.
|
||||
|
||||
Dust will list a slightly-less-than-the-terminal-height number of the biggest subdirectories or files and will smartly recurse down the tree to find the larger ones. There is no need for a '-d' flag or a '-h' flag. The largest subdirectories will be colored.
|
||||
|
||||
## Usage
|
||||
Dust will list the 15 biggest sub directories and will smartly recurse down the tree to find the larger ones. There is no need for a '-d' flag or a '-h' flag. The largest sub directory will have its size shown in red
|
||||
|
||||
```
|
||||
Usage: dust
|
||||
Usage: dust <dir>
|
||||
Usage: dust <dir> <another_dir> <and_more>
|
||||
Usage: dust -p <dir> (full-path - does not shorten the path of the subdirectories)
|
||||
Usage: dust -s <dir> (apparent-size - shows the length of the file as opposed to the amount of disk space it uses)
|
||||
Usage: dust -n 30 <dir> (shows 30 directories instead of the default)
|
||||
Usage: dust -d 3 <dir> (shows 3 levels of subdirectories)
|
||||
Usage: dust -r <dir> (reverse order of output, with root at the lowest)
|
||||
Usage: dust -x <dir> (only show directories on the same filesystem)
|
||||
Usage: dust -X ignore <dir> (ignore all files and directories with the name 'ignore')
|
||||
Usage: dust -b <dir> (do not show percentages or draw ASCII bars)
|
||||
Usage: dust -n 30 <dir> (Shows 30 directories not 15)
|
||||
```
|
||||
|
||||
|
||||
## Alternatives
|
||||
```
|
||||
dust .
|
||||
161M .
|
||||
160M └── ./target
|
||||
123M ├── ./target/debug
|
||||
83M │ ├── ./target/debug/deps
|
||||
16M │ │ ├── ./target/debug/deps/libclap-82e6176feef5d4b7.rlib
|
||||
8.6M │ │ └── ./target/debug/deps/dust-993f7d919d92f0f8.dSYM
|
||||
8.6M │ │ └── ./target/debug/deps/dust-993f7d919d92f0f8.dSYM/Contents
|
||||
8.6M │ │ └── ./target/debug/deps/dust-993f7d919d92f0f8.dSYM/Contents/Resources
|
||||
27M │ ├── ./target/debug/incremental
|
||||
12M │ └── ./target/debug/build
|
||||
20M ├── ./target/x86_64-apple-darwin
|
||||
20M │ └── ./target/x86_64-apple-darwin/debug
|
||||
20M │ └── ./target/x86_64-apple-darwin/debug/deps
|
||||
16M │ └── ./target/x86_64-apple-darwin/debug/deps/libclap-7e3f8513c52cd558.rlib
|
||||
16M └── ./target/release
|
||||
13M └── ./target/release/deps
|
||||
```
|
||||
|
||||
Performance: dust is currently about 4 times slower than du.
|
||||
|
||||
|
||||
|
||||
* [NCDU](https://dev.yorhel.nl/ncdu)
|
||||
* [dutree](https://github.com/nachoparker/dutree)
|
||||
* du -d 1 -h | sort -h
|
||||
|
||||
Note: Apparent-size is calculated slightly differently in dust to gdu. In dust each hard link is counted as using file_length space. In gdu only the first entry is counted.
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
# This script takes care of packaging the build artifacts that will go in the
|
||||
# release zipfile
|
||||
|
||||
$SRC_DIR = $PWD.Path
|
||||
$STAGE = [System.Guid]::NewGuid().ToString()
|
||||
|
||||
Set-Location $ENV:Temp
|
||||
New-Item -Type Directory -Name $STAGE
|
||||
Set-Location $STAGE
|
||||
|
||||
$ZIP = "$SRC_DIR\$($Env:CRATE_NAME)-$($Env:APPVEYOR_REPO_TAG_NAME)-$($Env:TARGET).zip"
|
||||
|
||||
# TODO Update this to package the right artifacts
|
||||
Copy-Item "$SRC_DIR\target\$($Env:TARGET)\release\dust" '.\'
|
||||
|
||||
7z a "$ZIP" *
|
||||
|
||||
Push-AppveyorArtifact "$ZIP"
|
||||
|
||||
Remove-Item *.* -Force
|
||||
Set-Location ..
|
||||
Remove-Item $STAGE
|
||||
Set-Location $SRC_DIR
|
||||
@@ -1,34 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# This script takes care of building your crate and packaging it for release
|
||||
|
||||
set -ex
|
||||
|
||||
main() {
|
||||
local src=$(pwd) \
|
||||
stage=
|
||||
|
||||
case $TRAVIS_OS_NAME in
|
||||
linux)
|
||||
stage=$(mktemp -d)
|
||||
;;
|
||||
osx)
|
||||
stage=$(mktemp -d -t tmp)
|
||||
;;
|
||||
esac
|
||||
|
||||
test -f Cargo.lock || cargo generate-lockfile
|
||||
|
||||
# TODO Update this to build the artifacts that matter to you
|
||||
cross rustc --bin dust --target $TARGET --release -- -C lto
|
||||
|
||||
# TODO Update this to package the right artifacts
|
||||
cp target/$TARGET/release/dust $stage/
|
||||
|
||||
cd $stage
|
||||
tar czf $src/$CRATE_NAME-$TRAVIS_TAG-$TARGET.tar.gz *
|
||||
cd $src
|
||||
|
||||
rm -rf $stage
|
||||
}
|
||||
|
||||
main
|
||||
@@ -1,9 +0,0 @@
|
||||
# ----------- To do a release ---------
|
||||
# tag a commit and push:
|
||||
# git tag v0.4.5
|
||||
# git push origin v0.4.5
|
||||
|
||||
# cargo publish to put it in crates.io
|
||||
|
||||
# To install locally [Do before pushing it]
|
||||
#cargo install --path .
|
||||
@@ -1,28 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -ex
|
||||
|
||||
main() {
|
||||
local target=
|
||||
if [ $TRAVIS_OS_NAME = linux ]; then
|
||||
target=x86_64-unknown-linux-musl
|
||||
sort=sort
|
||||
else
|
||||
target=x86_64-apple-darwin
|
||||
sort=gsort # for `sort --sort-version`, from brew's coreutils.
|
||||
fi
|
||||
|
||||
# This fetches latest stable release
|
||||
local tag=$(git ls-remote --tags --refs --exit-code https://github.com/japaric/cross \
|
||||
| cut -d/ -f3 \
|
||||
| grep -E '^v[0.1.0-9.]+$' \
|
||||
| $sort --version-sort \
|
||||
| tail -n1)
|
||||
curl -LSfs https://japaric.github.io/trust/install.sh | \
|
||||
sh -s -- \
|
||||
--force \
|
||||
--git japaric/cross \
|
||||
--tag $tag \
|
||||
--target $target
|
||||
}
|
||||
|
||||
main
|
||||
25
ci/script.sh
25
ci/script.sh
@@ -1,25 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# This script takes care of testing your crate
|
||||
|
||||
set -ex
|
||||
|
||||
# TODO This is the "test phase", tweak it as you see fit
|
||||
main() {
|
||||
cross build --target $TARGET
|
||||
cross build --target $TARGET --release
|
||||
|
||||
if [ ! -z $DISABLE_TESTS ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
cross test --target $TARGET
|
||||
cross test --target $TARGET --release
|
||||
|
||||
cross run --target $TARGET
|
||||
cross run --target $TARGET --release
|
||||
}
|
||||
|
||||
# we don't run the "test phase" when doing deploys
|
||||
if [ -z $TRAVIS_TAG ]; then
|
||||
main
|
||||
fi
|
||||
BIN
media/snap.png
BIN
media/snap.png
Binary file not shown.
|
Before Width: | Height: | Size: 61 KiB |
353
src/display.rs
353
src/display.rs
@@ -1,353 +0,0 @@
|
||||
extern crate ansi_term;
|
||||
|
||||
use crate::utils::Node;
|
||||
|
||||
use self::ansi_term::Colour::Red;
|
||||
use lscolors::{LsColors, Style};
|
||||
|
||||
use terminal_size::{terminal_size, Height, Width};
|
||||
|
||||
use unicode_width::UnicodeWidthStr;
|
||||
|
||||
use std::cmp::max;
|
||||
use std::cmp::min;
|
||||
use std::fs;
|
||||
use std::iter::repeat;
|
||||
use std::path::Path;
|
||||
|
||||
static UNITS: [char; 4] = ['T', 'G', 'M', 'K'];
|
||||
static BLOCKS: [char; 5] = ['█', '▓', '▒', '░', ' '];
|
||||
static DEFAULT_TERMINAL_WIDTH: u16 = 80;
|
||||
|
||||
pub struct DisplayData {
|
||||
pub short_paths: bool,
|
||||
pub is_reversed: bool,
|
||||
pub colors_on: bool,
|
||||
pub base_size: u64,
|
||||
pub longest_string_length: usize,
|
||||
pub ls_colors: LsColors,
|
||||
}
|
||||
|
||||
impl DisplayData {
|
||||
#[allow(clippy::collapsible_if)]
|
||||
fn get_tree_chars(&self, was_i_last: bool, has_children: bool) -> &'static str {
|
||||
if self.is_reversed {
|
||||
if was_i_last {
|
||||
if has_children {
|
||||
"┌─┴"
|
||||
} else {
|
||||
"┌──"
|
||||
}
|
||||
} else if has_children {
|
||||
"├─┴"
|
||||
} else {
|
||||
"├──"
|
||||
}
|
||||
} else {
|
||||
if was_i_last {
|
||||
if has_children {
|
||||
"└─┬"
|
||||
} else {
|
||||
"└──"
|
||||
}
|
||||
} else if has_children {
|
||||
"├─┬"
|
||||
} else {
|
||||
"├──"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn is_biggest(&self, num_siblings: usize, max_siblings: u64) -> bool {
|
||||
if self.is_reversed {
|
||||
num_siblings == (max_siblings - 1) as usize
|
||||
} else {
|
||||
num_siblings == 0
|
||||
}
|
||||
}
|
||||
|
||||
fn is_last(&self, num_siblings: usize, max_siblings: u64) -> bool {
|
||||
if self.is_reversed {
|
||||
num_siblings == 0
|
||||
} else {
|
||||
num_siblings == (max_siblings - 1) as usize
|
||||
}
|
||||
}
|
||||
|
||||
fn percent_size(&self, node: &Node) -> f32 {
|
||||
let result = node.size as f32 / self.base_size as f32;
|
||||
if result.is_normal() {
|
||||
result
|
||||
} else {
|
||||
0.0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn get_children_from_node(node: Node, is_reversed: bool) -> impl Iterator<Item = Node> {
|
||||
if is_reversed {
|
||||
let n: Vec<Node> = node.children.into_iter().rev().map(|a| a).collect();
|
||||
n.into_iter()
|
||||
} else {
|
||||
node.children.into_iter()
|
||||
}
|
||||
}
|
||||
|
||||
struct DrawData<'a> {
|
||||
indent: String,
|
||||
percent_bar: String,
|
||||
display_data: &'a DisplayData,
|
||||
}
|
||||
|
||||
impl DrawData<'_> {
|
||||
fn get_new_indent(&self, has_children: bool, was_i_last: bool) -> String {
|
||||
let chars = self.display_data.get_tree_chars(was_i_last, has_children);
|
||||
self.indent.to_string() + chars
|
||||
}
|
||||
|
||||
fn generate_bar(&self, node: &Node, level: usize) -> String {
|
||||
let chars_in_bar = self.percent_bar.chars().count();
|
||||
let num_bars = chars_in_bar as f32 * self.display_data.percent_size(node);
|
||||
let mut num_not_my_bar = (chars_in_bar as i32) - num_bars as i32;
|
||||
|
||||
let mut new_bar = "".to_string();
|
||||
let idx = 5 - min(5, max(1, level));
|
||||
|
||||
for c in self.percent_bar.chars() {
|
||||
num_not_my_bar -= 1;
|
||||
if num_not_my_bar <= 0 {
|
||||
new_bar.push(BLOCKS[0]);
|
||||
} else if c == BLOCKS[0] {
|
||||
new_bar.push(BLOCKS[idx]);
|
||||
} else {
|
||||
new_bar.push(c);
|
||||
}
|
||||
}
|
||||
new_bar
|
||||
}
|
||||
}
|
||||
|
||||
fn get_width_of_terminal() -> u16 {
|
||||
// Windows CI runners detect a very low terminal width
|
||||
if let Some((Width(w), Height(_h))) = terminal_size() {
|
||||
max(w, DEFAULT_TERMINAL_WIDTH)
|
||||
} else {
|
||||
DEFAULT_TERMINAL_WIDTH
|
||||
}
|
||||
}
|
||||
|
||||
pub fn draw_it(
|
||||
permissions: bool,
|
||||
use_full_path: bool,
|
||||
is_reversed: bool,
|
||||
no_colors: bool,
|
||||
no_percents: bool,
|
||||
root_node: Node,
|
||||
) {
|
||||
if !permissions {
|
||||
eprintln!("Did not have permissions for all directories");
|
||||
}
|
||||
let longest_string_length = root_node
|
||||
.children
|
||||
.iter()
|
||||
.map(|c| find_longest_dir_name(&c, " ", !use_full_path))
|
||||
.fold(0, max);
|
||||
let terminal_width = get_width_of_terminal() - 16;
|
||||
|
||||
let max_bar_length = if no_percents || longest_string_length >= terminal_width as usize {
|
||||
0
|
||||
} else {
|
||||
terminal_width as usize - longest_string_length
|
||||
};
|
||||
|
||||
// handle usize error also add do not show fancy output option
|
||||
let bar_text = repeat(BLOCKS[0]).take(max_bar_length).collect::<String>();
|
||||
|
||||
for c in get_children_from_node(root_node, is_reversed) {
|
||||
let display_data = DisplayData {
|
||||
short_paths: !use_full_path,
|
||||
is_reversed,
|
||||
colors_on: !no_colors,
|
||||
base_size: c.size,
|
||||
longest_string_length,
|
||||
ls_colors: LsColors::from_env().unwrap_or_default(),
|
||||
};
|
||||
let draw_data = DrawData {
|
||||
indent: "".to_string(),
|
||||
percent_bar: bar_text.clone(),
|
||||
display_data: &display_data,
|
||||
};
|
||||
display_node(c, &draw_data, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
// We can probably pass depth instead of indent here.
|
||||
// It is ugly to feed in ' ' instead of the actual tree characters but we don't need them yet.
|
||||
fn find_longest_dir_name(node: &Node, indent: &str, long_paths: bool) -> usize {
|
||||
let printable_name = get_printable_name(&node.name, long_paths);
|
||||
let longest = get_unicode_width_of_indent_and_name(indent, &printable_name);
|
||||
|
||||
// each none root tree drawing is 2 chars
|
||||
let full_indent: String = indent.to_string() + " ";
|
||||
node.children
|
||||
.iter()
|
||||
.map(|c| find_longest_dir_name(c, &*full_indent, long_paths))
|
||||
.fold(longest, max)
|
||||
}
|
||||
|
||||
fn display_node(node: Node, draw_data: &DrawData, is_biggest: bool, is_last: bool) {
|
||||
let indent2 = draw_data.get_new_indent(!node.children.is_empty(), is_last);
|
||||
// hacky way of working out how deep we are in the tree
|
||||
let level = ((indent2.chars().count() - 1) / 2) - 1;
|
||||
let bar_text = draw_data.generate_bar(&node, level);
|
||||
|
||||
let to_print = format_string(
|
||||
&node,
|
||||
&*indent2,
|
||||
&*bar_text,
|
||||
is_biggest,
|
||||
draw_data.display_data,
|
||||
);
|
||||
|
||||
if !draw_data.display_data.is_reversed {
|
||||
println!("{}", to_print)
|
||||
}
|
||||
|
||||
let dd = DrawData {
|
||||
indent: clean_indentation_string(&*indent2),
|
||||
percent_bar: bar_text,
|
||||
display_data: draw_data.display_data,
|
||||
};
|
||||
let num_siblings = node.children.len() as u64;
|
||||
|
||||
for (count, c) in get_children_from_node(node, draw_data.display_data.is_reversed).enumerate() {
|
||||
let is_biggest = dd.display_data.is_biggest(count, num_siblings);
|
||||
let was_i_last = dd.display_data.is_last(count, num_siblings);
|
||||
display_node(c, &dd, is_biggest, was_i_last);
|
||||
}
|
||||
|
||||
if draw_data.display_data.is_reversed {
|
||||
println!("{}", to_print)
|
||||
}
|
||||
}
|
||||
|
||||
fn clean_indentation_string(s: &str) -> String {
|
||||
let mut is: String = s.into();
|
||||
// For reversed:
|
||||
is = is.replace("┌─┴", " ");
|
||||
is = is.replace("┌──", " ");
|
||||
is = is.replace("├─┴", "│ ");
|
||||
is = is.replace("─┴", " ");
|
||||
// For normal
|
||||
is = is.replace("└─┬", " ");
|
||||
is = is.replace("└──", " ");
|
||||
is = is.replace("├─┬", "│ ");
|
||||
is = is.replace("─┬", " ");
|
||||
// For both
|
||||
is = is.replace("├──", "│ ");
|
||||
is
|
||||
}
|
||||
|
||||
fn get_printable_name<P: AsRef<Path>>(dir_name: &P, long_paths: bool) -> String {
|
||||
let dir_name = dir_name.as_ref();
|
||||
let printable_name = {
|
||||
if long_paths {
|
||||
match dir_name.parent() {
|
||||
Some(prefix) => match dir_name.strip_prefix(prefix) {
|
||||
Ok(base) => base,
|
||||
Err(_) => dir_name,
|
||||
},
|
||||
None => dir_name,
|
||||
}
|
||||
} else {
|
||||
dir_name
|
||||
}
|
||||
};
|
||||
printable_name.display().to_string()
|
||||
}
|
||||
|
||||
fn get_unicode_width_of_indent_and_name(indent: &str, name: &str) -> usize {
|
||||
let indent_and_name = format!("{} {}", indent, name);
|
||||
UnicodeWidthStr::width(&*indent_and_name)
|
||||
}
|
||||
|
||||
pub fn format_string(
|
||||
node: &Node,
|
||||
indent: &str,
|
||||
percent_bar: &str,
|
||||
is_biggest: bool,
|
||||
display_data: &DisplayData,
|
||||
) -> String {
|
||||
let pretty_size = format!("{:>5}", human_readable_number(node.size));
|
||||
|
||||
let percent_size_str = format!("{:.0}%", display_data.percent_size(node) * 100.0);
|
||||
|
||||
let name = get_printable_name(&node.name, display_data.short_paths);
|
||||
let width = get_unicode_width_of_indent_and_name(indent, &name);
|
||||
|
||||
let (percents, name_and_padding) = if percent_bar != "" {
|
||||
let percents = format!("│{} │ {:>4}", percent_bar, percent_size_str);
|
||||
|
||||
let name_and_padding = name
|
||||
+ &(repeat(" ")
|
||||
.take(display_data.longest_string_length - width)
|
||||
.collect::<String>());
|
||||
(percents, name_and_padding)
|
||||
} else {
|
||||
("".into(), name)
|
||||
};
|
||||
|
||||
let pretty_size = if is_biggest && display_data.colors_on {
|
||||
format!("{}", Red.paint(pretty_size))
|
||||
} else {
|
||||
pretty_size
|
||||
};
|
||||
|
||||
let pretty_name = if display_data.colors_on {
|
||||
let meta_result = fs::metadata(node.name.clone());
|
||||
let directory_color = display_data
|
||||
.ls_colors
|
||||
.style_for_path_with_metadata(node.name.clone(), meta_result.as_ref().ok());
|
||||
let ansi_style = directory_color
|
||||
.map(Style::to_ansi_term_style)
|
||||
.unwrap_or_default();
|
||||
format!("{}", ansi_style.paint(name_and_padding))
|
||||
} else {
|
||||
name_and_padding
|
||||
};
|
||||
|
||||
format!("{} {} {}{}", pretty_size, indent, pretty_name, percents)
|
||||
}
|
||||
|
||||
fn human_readable_number(size: u64) -> String {
|
||||
for (i, u) in UNITS.iter().enumerate() {
|
||||
let marker = 1024u64.pow((UNITS.len() - i) as u32);
|
||||
if size >= marker {
|
||||
if size / marker < 10 {
|
||||
return format!("{:.1}{}", (size as f32 / marker as f32), u);
|
||||
} else {
|
||||
return format!("{}{}", (size / marker), u);
|
||||
}
|
||||
}
|
||||
}
|
||||
return format!("{}B", size);
|
||||
}
|
||||
|
||||
mod tests {
|
||||
#[allow(unused_imports)]
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_human_readable_number() {
|
||||
assert_eq!(human_readable_number(1), "1B");
|
||||
assert_eq!(human_readable_number(956), "956B");
|
||||
assert_eq!(human_readable_number(1004), "1004B");
|
||||
assert_eq!(human_readable_number(1024), "1.0K");
|
||||
assert_eq!(human_readable_number(1536), "1.5K");
|
||||
assert_eq!(human_readable_number(1024 * 512), "512K");
|
||||
assert_eq!(human_readable_number(1024 * 1024), "1.0M");
|
||||
assert_eq!(human_readable_number(1024 * 1024 * 1024 - 1), "1023M");
|
||||
assert_eq!(human_readable_number(1024 * 1024 * 1024 * 20), "20G");
|
||||
assert_eq!(human_readable_number(1024 * 1024 * 1024 * 1024), "1.0T");
|
||||
}
|
||||
}
|
||||
502
src/main.rs
502
src/main.rs
@@ -1,218 +1,364 @@
|
||||
// test:
|
||||
// recursive dirs that link to each other.
|
||||
// Pass in bad dir name
|
||||
// num to search for is less than num available
|
||||
// admin files.
|
||||
//
|
||||
extern crate ansi_term;
|
||||
#[macro_use]
|
||||
extern crate clap;
|
||||
extern crate crossbeam_channel as channel;
|
||||
extern crate ignore;
|
||||
extern crate unicode_width;
|
||||
extern crate walkdir;
|
||||
|
||||
use self::display::draw_it;
|
||||
use crate::utils::is_a_parent_of;
|
||||
use std::collections::HashSet;
|
||||
|
||||
use ansi_term::Colour::Fixed;
|
||||
use clap::{App, AppSettings, Arg};
|
||||
use std::cmp::max;
|
||||
use std::path::PathBuf;
|
||||
use terminal_size::{terminal_size, Height, Width};
|
||||
use utils::{find_big_ones, get_dir_tree, simplify_dir_names, sort, Node};
|
||||
|
||||
mod display;
|
||||
mod utils;
|
||||
use std::cmp;
|
||||
use std::cmp::Ordering;
|
||||
use std::fs;
|
||||
use std::fs::ReadDir;
|
||||
use std::io;
|
||||
|
||||
static DEFAULT_NUMBER_OF_LINES: usize = 30;
|
||||
#[derive(Clone, Debug)]
|
||||
struct Node {
|
||||
dir: Dir,
|
||||
children: Vec<Node>,
|
||||
}
|
||||
impl Ord for Node {
|
||||
fn cmp(&self, other: &Self) -> Ordering {
|
||||
if self.dir.size > other.dir.size {
|
||||
Ordering::Less
|
||||
} else if self.dir.size < other.dir.size {
|
||||
Ordering::Greater
|
||||
} else {
|
||||
let my_slashes = self.dir.name.matches("/").count();
|
||||
let other_slashes = other.dir.name.matches("/").count();
|
||||
|
||||
#[cfg(windows)]
|
||||
fn init_color(no_color: bool) -> bool {
|
||||
// If no color is already set do not print a warning message
|
||||
if no_color {
|
||||
true
|
||||
} else {
|
||||
// Required for windows 10
|
||||
// Fails to resolve for windows 8 so disable color
|
||||
match ansi_term::enable_ansi_support() {
|
||||
Ok(_) => no_color,
|
||||
Err(_) => {
|
||||
eprintln!(
|
||||
"This version of Windows does not support ANSI colors, setting no_color flag"
|
||||
);
|
||||
true
|
||||
if my_slashes > other_slashes {
|
||||
Ordering::Greater
|
||||
} else if my_slashes < other_slashes {
|
||||
Ordering::Less
|
||||
} else {
|
||||
if self.dir.name < other.dir.name {
|
||||
Ordering::Less
|
||||
} else if self.dir.name > other.dir.name {
|
||||
Ordering::Greater
|
||||
} else {
|
||||
Ordering::Equal
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
fn init_color(no_color: bool) -> bool {
|
||||
no_color
|
||||
}
|
||||
|
||||
fn get_height_of_terminal() -> usize {
|
||||
// Windows CI runners detect a terminal height of 0
|
||||
if let Some((Width(_w), Height(h))) = terminal_size() {
|
||||
max(h as usize, DEFAULT_NUMBER_OF_LINES) - 10
|
||||
} else {
|
||||
DEFAULT_NUMBER_OF_LINES - 10
|
||||
impl PartialOrd for Node {
|
||||
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||
Some(self.cmp(other))
|
||||
}
|
||||
}
|
||||
impl PartialEq for Node {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
(&self.dir.name, self.dir.size) == (&other.dir.name, other.dir.size)
|
||||
}
|
||||
}
|
||||
impl Eq for Node {}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
struct Dir {
|
||||
name: String,
|
||||
size: u64,
|
||||
}
|
||||
|
||||
static DEFAULT_NUMBER_OF_LINES: &'static str = &"15";
|
||||
|
||||
fn main() {
|
||||
let default_height = get_height_of_terminal();
|
||||
let def_num_str = default_height.to_string();
|
||||
|
||||
let options = App::new("Dust")
|
||||
.about("Like du but more intuitive")
|
||||
.version(crate_version!())
|
||||
let options = App::new("Trailing args example")
|
||||
.setting(AppSettings::TrailingVarArg)
|
||||
.arg(
|
||||
Arg::with_name("depth")
|
||||
.short("d")
|
||||
.long("depth")
|
||||
.help("Depth to show")
|
||||
.takes_value(true),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("number_of_lines")
|
||||
.short("n")
|
||||
.long("number-of-lines")
|
||||
.help("Number of lines of output to show")
|
||||
.takes_value(true)
|
||||
.default_value(def_num_str.as_ref()),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("display_full_paths")
|
||||
.short("p")
|
||||
.long("full-paths")
|
||||
.help("Subdirectories will not have their path shortened"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("ignore_directory")
|
||||
.short("X")
|
||||
.long("ignore-directory")
|
||||
.takes_value(true)
|
||||
.number_of_values(1)
|
||||
.multiple(true)
|
||||
.help("Exclude any file or directory with this name"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("limit_filesystem")
|
||||
.short("x")
|
||||
.long("limit-filesystem")
|
||||
.help("Only count the files and directories on the same filesystem as the supplied directory"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("display_apparent_size")
|
||||
.short("s")
|
||||
.long("apparent-size")
|
||||
.help("Use file length instead of blocks"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("reverse")
|
||||
.short("r")
|
||||
.long("reverse")
|
||||
.help("Print tree upside down (biggest highest)"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("no_colors")
|
||||
.short("c")
|
||||
.long("no-colors")
|
||||
.help("No colors will be printed (normally largest directories are colored)"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("no_bars")
|
||||
.short("b")
|
||||
.long("no-percent-bars")
|
||||
.help("No percent bars or percentages will be displayed"),
|
||||
.default_value(DEFAULT_NUMBER_OF_LINES),
|
||||
)
|
||||
.arg(Arg::with_name("inputs").multiple(true))
|
||||
.get_matches();
|
||||
|
||||
let target_dirs = {
|
||||
let filenames = {
|
||||
match options.values_of("inputs") {
|
||||
None => vec!["."],
|
||||
Some(r) => r.collect(),
|
||||
}
|
||||
};
|
||||
let number_of_lines = value_t!(options.value_of("number_of_lines"), usize).unwrap();
|
||||
|
||||
let number_of_lines = match value_t!(options.value_of("number_of_lines"), usize) {
|
||||
Ok(v) => v,
|
||||
Err(_) => {
|
||||
eprintln!("Ignoring bad value for number_of_lines");
|
||||
default_height
|
||||
}
|
||||
};
|
||||
|
||||
let depth = options.value_of("depth").and_then(|depth| {
|
||||
depth
|
||||
.parse::<usize>()
|
||||
.map(|v| v + 1)
|
||||
.map_err(|_| eprintln!("Ignoring bad value for depth"))
|
||||
.ok()
|
||||
});
|
||||
if options.is_present("depth") && number_of_lines != default_height {
|
||||
eprintln!("Use either -n or -d. Not both");
|
||||
return;
|
||||
}
|
||||
|
||||
let no_colors = init_color(options.is_present("no_colors"));
|
||||
let use_apparent_size = options.is_present("display_apparent_size");
|
||||
let limit_filesystem = options.is_present("limit_filesystem");
|
||||
let ignore_directories = match options.values_of("ignore_directory") {
|
||||
Some(i) => Some(i.map(PathBuf::from).collect()),
|
||||
None => None,
|
||||
};
|
||||
|
||||
let simplified_dirs = simplify_dir_names(target_dirs);
|
||||
let (permissions, nodes) = get_dir_tree(
|
||||
&simplified_dirs,
|
||||
&ignore_directories,
|
||||
use_apparent_size,
|
||||
limit_filesystem,
|
||||
depth,
|
||||
);
|
||||
let sorted_data = sort(nodes);
|
||||
let biggest_ones = {
|
||||
match depth {
|
||||
None => find_big_ones(sorted_data, number_of_lines + simplified_dirs.len()),
|
||||
Some(_) => sorted_data,
|
||||
}
|
||||
};
|
||||
let tree = build_tree(biggest_ones, depth);
|
||||
|
||||
draw_it(
|
||||
permissions,
|
||||
options.is_present("display_full_paths"),
|
||||
!options.is_present("reverse"),
|
||||
no_colors,
|
||||
options.is_present("no_bars"),
|
||||
tree,
|
||||
);
|
||||
let (permissions, results) = get_dir_tree(filenames);
|
||||
let slice_it = find_big_ones(&results, number_of_lines);
|
||||
display(permissions, slice_it);
|
||||
}
|
||||
|
||||
fn build_tree(biggest_ones: Vec<(PathBuf, u64)>, depth: Option<usize>) -> Node {
|
||||
let mut top_parent = Node::default();
|
||||
|
||||
// assume sorted order
|
||||
for b in biggest_ones {
|
||||
let n = Node {
|
||||
name: b.0,
|
||||
size: b.1,
|
||||
children: Vec::default(),
|
||||
};
|
||||
recursively_build_tree(&mut top_parent, n, depth);
|
||||
fn get_dir_tree(filenames: Vec<&str>) -> (bool, Vec<Node>) {
|
||||
let mut permissions = true;
|
||||
let mut results = vec![];
|
||||
for b in filenames {
|
||||
let mut new_name = String::from(b);
|
||||
while new_name.chars().last() == Some('/') && new_name.len() != 1 {
|
||||
new_name.pop();
|
||||
}
|
||||
let (hp, data) = examine_dir_str(new_name);
|
||||
permissions = permissions && hp;
|
||||
results.push(data);
|
||||
}
|
||||
top_parent
|
||||
(permissions, results)
|
||||
}
|
||||
|
||||
fn recursively_build_tree(parent_node: &mut Node, new_node: Node, depth: Option<usize>) {
|
||||
let new_depth = match depth {
|
||||
fn examine_dir_str(loc: String) -> (bool, Node) {
|
||||
let mut inodes: HashSet<u64> = HashSet::new();
|
||||
let (hp, result) = examine_dir(fs::read_dir(&loc), &mut inodes);
|
||||
|
||||
// This needs to be folded into the below recursive call somehow
|
||||
let new_size = result.iter().fold(0, |a, b| a + b.dir.size);
|
||||
(
|
||||
hp,
|
||||
Node {
|
||||
dir: Dir {
|
||||
name: loc,
|
||||
size: new_size,
|
||||
},
|
||||
children: result,
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
fn get_metadata_blocks_and_inode(d: &std::fs::DirEntry) -> Option<(u64, u64)> {
|
||||
use std::os::linux::fs::MetadataExt;
|
||||
match d.metadata().ok() {
|
||||
Some(md) => Some((md.len(), md.st_ino())),
|
||||
None => None,
|
||||
Some(0) => return,
|
||||
Some(d) => Some(d - 1),
|
||||
};
|
||||
if let Some(c) = parent_node
|
||||
.children
|
||||
.iter_mut()
|
||||
.find(|c| is_a_parent_of(&c.name, &new_node.name))
|
||||
{
|
||||
recursively_build_tree(c, new_node, new_depth);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "unix")]
|
||||
fn get_metadata_blocks_and_inode(d: &std::fs::DirEntry) -> Option<(u64, u64)> {
|
||||
use std::os::unix::fs::MetadataExt;
|
||||
match d.metadata().ok() {
|
||||
Some(md) => Some((md.len(), md.ino())),
|
||||
None => None,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
fn get_metadata_blocks_and_inode(d: &std::fs::DirEntry) -> Option<(u64, u64)> {
|
||||
use std::os::macos::fs::MetadataExt;
|
||||
match d.metadata().ok() {
|
||||
Some(md) => Some((md.len(), md.st_ino())),
|
||||
None => None,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_os = "linux", target_os = "unix", target_os = "macos")))]
|
||||
fn get_metadata_blocks_and_inode(_d: &std::fs::DirEntry) -> Option<(u64, u64)> {
|
||||
match d.metadata().ok() {
|
||||
Some(md) => Some((md.len(), 0)), //move to option not 0
|
||||
None => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn examine_dir(a_dir: io::Result<ReadDir>, inodes: &mut HashSet<u64>) -> (bool, Vec<Node>) {
|
||||
let mut result = vec![];
|
||||
let mut have_permission = true;
|
||||
|
||||
if a_dir.is_ok() {
|
||||
let paths = a_dir.unwrap();
|
||||
for dd in paths {
|
||||
match dd {
|
||||
Ok(d) => {
|
||||
let file_type = d.file_type().ok();
|
||||
let maybe_size_and_inode = get_metadata_blocks_and_inode(&d);
|
||||
|
||||
match (file_type, maybe_size_and_inode) {
|
||||
(Some(file_type), Some((size, inode))) => {
|
||||
let s = d.path().to_string_lossy().to_string();
|
||||
if inodes.contains(&inode) {
|
||||
continue;
|
||||
}
|
||||
inodes.insert(inode);
|
||||
|
||||
if d.path().is_dir() && !file_type.is_symlink() {
|
||||
let (hp, recursive) = examine_dir(fs::read_dir(d.path()), inodes);
|
||||
have_permission = have_permission && hp;
|
||||
let new_size = recursive.iter().fold(size, |a, b| a + b.dir.size);
|
||||
result.push(Node {
|
||||
dir: Dir {
|
||||
name: s,
|
||||
size: new_size,
|
||||
},
|
||||
children: recursive,
|
||||
})
|
||||
} else {
|
||||
result.push(Node {
|
||||
dir: Dir {
|
||||
name: s,
|
||||
size: size,
|
||||
},
|
||||
children: vec![],
|
||||
})
|
||||
}
|
||||
}
|
||||
(_, None) => have_permission = false,
|
||||
(_, _) => (),
|
||||
}
|
||||
}
|
||||
Err(_) => (),
|
||||
}
|
||||
}
|
||||
} else {
|
||||
parent_node.children.push(new_node);
|
||||
have_permission = false;
|
||||
}
|
||||
(have_permission, result)
|
||||
}
|
||||
|
||||
// We start with a list of root directories - these must be the biggest folders
|
||||
// We then repeadedly merge in the children of the biggest directory - Each iteration
|
||||
// the next biggest directory's children are merged in.
|
||||
fn find_big_ones<'a>(l: &'a Vec<Node>, max_to_show: usize) -> Vec<&Node> {
|
||||
let mut new_l: Vec<&Node> = l.iter().map(|a| a).collect();
|
||||
new_l.sort();
|
||||
|
||||
for processed_pointer in 0..max_to_show {
|
||||
if new_l.len() == processed_pointer {
|
||||
break;
|
||||
}
|
||||
// Must be a list of pointers into new_l otherwise b_list will go out of scope
|
||||
// when it is deallocated
|
||||
let mut b_list: Vec<&Node> = new_l[processed_pointer]
|
||||
.children
|
||||
.iter()
|
||||
.map(|a| a)
|
||||
.collect();
|
||||
new_l.extend(b_list);
|
||||
new_l.sort();
|
||||
/*println!(
|
||||
"{:?} -------------------",
|
||||
new_l
|
||||
.iter()
|
||||
.map(|a| a.dir.size.to_string() + ": " + &a.dir.name)
|
||||
.collect::<Vec<String>>()
|
||||
);*/
|
||||
}
|
||||
if new_l.len() > max_to_show {
|
||||
new_l[0..max_to_show + 1].to_vec()
|
||||
} else {
|
||||
new_l
|
||||
}
|
||||
}
|
||||
|
||||
fn display(permissions: bool, to_display: Vec<&Node>) -> () {
|
||||
if !permissions {
|
||||
eprintln!("Did not have permissions for all directories");
|
||||
}
|
||||
|
||||
display_node(to_display[0], &to_display, true, 1, "")
|
||||
}
|
||||
|
||||
fn display_node<S: Into<String>>(
|
||||
node_to_print: &Node,
|
||||
to_display: &Vec<&Node>,
|
||||
is_first: bool,
|
||||
depth: u8,
|
||||
indentation_str: S,
|
||||
) {
|
||||
let mut is = indentation_str.into();
|
||||
print_this_node(node_to_print, is_first, depth, is.as_ref());
|
||||
|
||||
is = is.replace("└──", " ");
|
||||
is = is.replace("├──", "│ ");
|
||||
|
||||
let printable_node_slashes = node_to_print.dir.name.matches("/").count();
|
||||
|
||||
let mut num_sibblings = to_display.iter().fold(0, |a, b| {
|
||||
if node_to_print.children.contains(b)
|
||||
&& b.dir.name.matches("/").count() == printable_node_slashes + 1
|
||||
{
|
||||
a + 1
|
||||
} else {
|
||||
a
|
||||
}
|
||||
});
|
||||
|
||||
let mut is_biggest = true;
|
||||
for node in to_display {
|
||||
if node_to_print.children.contains(node) {
|
||||
if node.dir.name.matches("/").count() == printable_node_slashes + 1 {
|
||||
num_sibblings -= 1;
|
||||
let tree_chars = {
|
||||
if num_sibblings == 0 {
|
||||
"└──"
|
||||
} else {
|
||||
"├──"
|
||||
}
|
||||
};
|
||||
display_node(
|
||||
&node,
|
||||
to_display,
|
||||
is_biggest,
|
||||
depth + 1,
|
||||
is.to_string() + tree_chars,
|
||||
);
|
||||
is_biggest = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn print_this_node(node_to_print: &Node, is_biggest: bool, depth: u8, indentation_str: &str) {
|
||||
let padded_size = format!("{:>5}", human_readable_number(node_to_print.dir.size),);
|
||||
println!(
|
||||
"{} {} {}",
|
||||
if is_biggest {
|
||||
Fixed(196).paint(padded_size)
|
||||
} else {
|
||||
Fixed(7).paint(padded_size)
|
||||
},
|
||||
indentation_str,
|
||||
Fixed(7)
|
||||
.on(Fixed(cmp::min(8, (depth) as u8) + 231))
|
||||
.paint(node_to_print.dir.name.to_string())
|
||||
);
|
||||
}
|
||||
|
||||
fn human_readable_number(size: u64) -> (String) {
|
||||
let units = vec!["T", "G", "M", "K"]; //make static
|
||||
|
||||
//return format!("{}B", size);
|
||||
|
||||
for (i, u) in units.iter().enumerate() {
|
||||
let marker = 1024u64.pow((units.len() - i) as u32);
|
||||
if size >= marker {
|
||||
if size / marker < 10 {
|
||||
return format!("{:.1}{}", (size as f32 / marker as f32), u);
|
||||
} else {
|
||||
return format!("{}{}", (size / marker), u);
|
||||
}
|
||||
}
|
||||
}
|
||||
return format!("{}B", size);
|
||||
}
|
||||
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_human_readable_number() {
|
||||
assert_eq!(human_readable_number(1), "1B");
|
||||
assert_eq!(human_readable_number(956), "956B");
|
||||
assert_eq!(human_readable_number(1004), "1004B");
|
||||
assert_eq!(human_readable_number(1024), "1.0K");
|
||||
assert_eq!(human_readable_number(1536), "1.5K");
|
||||
assert_eq!(human_readable_number(1024 * 512), "512K");
|
||||
assert_eq!(human_readable_number(1024 * 1024), "1.0M");
|
||||
assert_eq!(human_readable_number(1024 * 1024 * 1024 - 1), "1023M");
|
||||
assert_eq!(human_readable_number(1024 * 1024 * 1024 * 20), "20G");
|
||||
assert_eq!(human_readable_number(1024 * 1024 * 1024 * 1024), "1.0T");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
hello
|
||||
@@ -1 +0,0 @@
|
||||
hello
|
||||
@@ -1 +0,0 @@
|
||||
hello
|
||||
@@ -1 +0,0 @@
|
||||
hello
|
||||
357
src/utils/mod.rs
357
src/utils/mod.rs
@@ -1,357 +0,0 @@
|
||||
use std::cmp::Ordering;
|
||||
use std::collections::HashMap;
|
||||
use std::collections::HashSet;
|
||||
use std::iter::FromIterator;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::sync::atomic::AtomicBool;
|
||||
|
||||
use channel::Receiver;
|
||||
use std::thread::JoinHandle;
|
||||
|
||||
use ignore::{WalkBuilder, WalkState};
|
||||
use std::sync::atomic;
|
||||
use std::thread;
|
||||
|
||||
mod platform;
|
||||
use self::platform::*;
|
||||
|
||||
type PathData = (PathBuf, u64, Option<(u64, u64)>);
|
||||
|
||||
#[derive(Debug, Default, Eq)]
|
||||
pub struct Node {
|
||||
pub name: PathBuf,
|
||||
pub size: u64,
|
||||
pub children: Vec<Node>,
|
||||
}
|
||||
|
||||
impl Ord for Node {
|
||||
fn cmp(&self, other: &Self) -> Ordering {
|
||||
if self.size == other.size {
|
||||
self.name.cmp(&other.name)
|
||||
} else {
|
||||
self.size.cmp(&other.size)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialOrd for Node {
|
||||
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||
Some(self.cmp(other))
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq for Node {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.name == other.name && self.size == other.size && self.children == other.children
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_a_parent_of<P: AsRef<Path>>(parent: P, child: P) -> bool {
|
||||
let parent = parent.as_ref();
|
||||
let child = child.as_ref();
|
||||
child.starts_with(parent) && !parent.starts_with(child)
|
||||
}
|
||||
|
||||
pub fn simplify_dir_names<P: AsRef<Path>>(filenames: Vec<P>) -> HashSet<PathBuf> {
|
||||
let mut top_level_names: HashSet<PathBuf> = HashSet::with_capacity(filenames.len());
|
||||
let mut to_remove: Vec<PathBuf> = Vec::with_capacity(filenames.len());
|
||||
|
||||
for t in filenames {
|
||||
let top_level_name = normalize_path(t);
|
||||
let mut can_add = true;
|
||||
|
||||
for tt in top_level_names.iter() {
|
||||
if is_a_parent_of(&top_level_name, tt) {
|
||||
to_remove.push(tt.to_path_buf());
|
||||
} else if is_a_parent_of(tt, &top_level_name) {
|
||||
can_add = false;
|
||||
}
|
||||
}
|
||||
to_remove.sort_unstable();
|
||||
top_level_names.retain(|tr| to_remove.binary_search(tr).is_err());
|
||||
to_remove.clear();
|
||||
if can_add {
|
||||
top_level_names.insert(top_level_name);
|
||||
}
|
||||
}
|
||||
|
||||
top_level_names
|
||||
}
|
||||
|
||||
fn prepare_walk_dir_builder<P: AsRef<Path>>(
|
||||
top_level_names: &HashSet<P>,
|
||||
limit_filesystem: bool,
|
||||
max_depth: Option<usize>,
|
||||
) -> WalkBuilder {
|
||||
let mut it = top_level_names.iter();
|
||||
let mut builder = WalkBuilder::new(it.next().unwrap());
|
||||
builder.follow_links(false);
|
||||
builder.ignore(false);
|
||||
builder.git_global(false);
|
||||
builder.git_ignore(false);
|
||||
builder.git_exclude(false);
|
||||
builder.hidden(false);
|
||||
|
||||
if limit_filesystem {
|
||||
builder.same_file_system(true);
|
||||
}
|
||||
|
||||
builder.max_depth(max_depth);
|
||||
|
||||
for b in it {
|
||||
builder.add(b);
|
||||
}
|
||||
builder
|
||||
}
|
||||
|
||||
pub fn get_dir_tree<P: AsRef<Path>>(
|
||||
top_level_names: &HashSet<P>,
|
||||
ignore_directories: &Option<Vec<PathBuf>>,
|
||||
apparent_size: bool,
|
||||
limit_filesystem: bool,
|
||||
max_depth: Option<usize>,
|
||||
) -> (bool, HashMap<PathBuf, u64>) {
|
||||
let (tx, rx) = channel::bounded::<PathData>(1000);
|
||||
|
||||
let permissions_flag = AtomicBool::new(true);
|
||||
|
||||
let t2 = HashSet::from_iter(top_level_names.iter().map(|p| p.as_ref().to_path_buf()));
|
||||
|
||||
let t = create_reader_thread(rx, t2, apparent_size);
|
||||
let walk_dir_builder = prepare_walk_dir_builder(top_level_names, limit_filesystem, max_depth);
|
||||
|
||||
walk_dir_builder.build_parallel().run(|| {
|
||||
let txc = tx.clone();
|
||||
let pf = &permissions_flag;
|
||||
Box::new(move |path| {
|
||||
match path {
|
||||
Ok(p) => {
|
||||
if let Some(dirs) = ignore_directories {
|
||||
let path = p.path();
|
||||
let parts = path.components().collect::<Vec<std::path::Component>>();
|
||||
for d in dirs {
|
||||
let seq = d.components().collect::<Vec<std::path::Component>>();
|
||||
if parts
|
||||
.windows(seq.len())
|
||||
.any(|window| window.iter().collect::<PathBuf>() == *d)
|
||||
{
|
||||
return WalkState::Continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let maybe_size_and_inode = get_metadata(&p, apparent_size);
|
||||
|
||||
match maybe_size_and_inode {
|
||||
Some(data) => {
|
||||
let (size, inode_device) = data;
|
||||
txc.send((p.into_path(), size, inode_device)).unwrap();
|
||||
}
|
||||
None => {
|
||||
pf.store(false, atomic::Ordering::Relaxed);
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(_) => {
|
||||
pf.store(false, atomic::Ordering::Relaxed);
|
||||
}
|
||||
};
|
||||
WalkState::Continue
|
||||
})
|
||||
});
|
||||
|
||||
drop(tx);
|
||||
let data = t.join().unwrap();
|
||||
(permissions_flag.load(atomic::Ordering::SeqCst), data)
|
||||
}
|
||||
|
||||
fn create_reader_thread(
|
||||
rx: Receiver<PathData>,
|
||||
top_level_names: HashSet<PathBuf>,
|
||||
apparent_size: bool,
|
||||
) -> JoinHandle<HashMap<PathBuf, u64>> {
|
||||
// Receiver thread
|
||||
thread::spawn(move || {
|
||||
let mut hash: HashMap<PathBuf, u64> = HashMap::new();
|
||||
let mut inodes: HashSet<(u64, u64)> = HashSet::new();
|
||||
|
||||
for dent in rx {
|
||||
let (path, size, maybe_inode_device) = dent;
|
||||
|
||||
if should_ignore_file(apparent_size, &mut inodes, maybe_inode_device) {
|
||||
continue;
|
||||
} else {
|
||||
for p in path.ancestors() {
|
||||
let s = hash.entry(p.to_path_buf()).or_insert(0);
|
||||
*s += size;
|
||||
|
||||
if top_level_names.contains(p) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
hash
|
||||
})
|
||||
}
|
||||
|
||||
pub fn normalize_path<P: AsRef<Path>>(path: P) -> PathBuf {
|
||||
// normalize path ...
|
||||
// 1. removing repeated separators
|
||||
// 2. removing interior '.' ("current directory") path segments
|
||||
// 3. removing trailing extra separators and '.' ("current directory") path segments
|
||||
// * `Path.components()` does all the above work; ref: <https://doc.rust-lang.org/std/path/struct.Path.html#method.components>
|
||||
// 4. changing to os preferred separator (automatically done by recollecting components back into a PathBuf)
|
||||
path.as_ref().components().collect::<PathBuf>()
|
||||
}
|
||||
|
||||
fn should_ignore_file(
|
||||
apparent_size: bool,
|
||||
inodes: &mut HashSet<(u64, u64)>,
|
||||
maybe_inode_device: Option<(u64, u64)>,
|
||||
) -> bool {
|
||||
match maybe_inode_device {
|
||||
None => false,
|
||||
Some(data) => {
|
||||
let (inode, device) = data;
|
||||
if !apparent_size {
|
||||
// Ignore files already visited or symlinked
|
||||
if inodes.contains(&(inode, device)) {
|
||||
return true;
|
||||
}
|
||||
inodes.insert((inode, device));
|
||||
}
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn sort_by_size_first_name_second(a: &(PathBuf, u64), b: &(PathBuf, u64)) -> Ordering {
|
||||
let result = b.1.cmp(&a.1);
|
||||
if result == Ordering::Equal {
|
||||
a.0.cmp(&b.0)
|
||||
} else {
|
||||
result
|
||||
}
|
||||
}
|
||||
|
||||
pub fn sort(data: HashMap<PathBuf, u64>) -> Vec<(PathBuf, u64)> {
|
||||
let mut new_l: Vec<(PathBuf, u64)> = data.iter().map(|(a, b)| (a.clone(), *b)).collect();
|
||||
new_l.sort_unstable_by(sort_by_size_first_name_second);
|
||||
new_l
|
||||
}
|
||||
|
||||
pub fn find_big_ones(new_l: Vec<(PathBuf, u64)>, max_to_show: usize) -> Vec<(PathBuf, u64)> {
|
||||
if max_to_show > 0 && new_l.len() > max_to_show {
|
||||
new_l[0..max_to_show].to_vec()
|
||||
} else {
|
||||
new_l
|
||||
}
|
||||
}
|
||||
|
||||
mod tests {
|
||||
#[allow(unused_imports)]
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_simplify_dir() {
|
||||
let mut correct = HashSet::new();
|
||||
correct.insert(PathBuf::from("a"));
|
||||
assert_eq!(simplify_dir_names(vec!["a"]), correct);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_simplify_dir_rm_subdir() {
|
||||
let mut correct = HashSet::new();
|
||||
correct.insert(["a", "b"].iter().collect::<PathBuf>());
|
||||
assert_eq!(simplify_dir_names(vec!["a/b", "a/b/c", "a/b/d/f"]), correct);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_simplify_dir_duplicates() {
|
||||
let mut correct = HashSet::new();
|
||||
correct.insert(["a", "b"].iter().collect::<PathBuf>());
|
||||
correct.insert(PathBuf::from("c"));
|
||||
assert_eq!(
|
||||
simplify_dir_names(vec![
|
||||
"a/b",
|
||||
"a/b//",
|
||||
"a/././b///",
|
||||
"c",
|
||||
"c/",
|
||||
"c/.",
|
||||
"c/././",
|
||||
"c/././."
|
||||
]),
|
||||
correct
|
||||
);
|
||||
}
|
||||
#[test]
|
||||
fn test_simplify_dir_rm_subdir_and_not_substrings() {
|
||||
let mut correct = HashSet::new();
|
||||
correct.insert(PathBuf::from("b"));
|
||||
correct.insert(["c", "a", "b"].iter().collect::<PathBuf>());
|
||||
correct.insert(["a", "b"].iter().collect::<PathBuf>());
|
||||
assert_eq!(simplify_dir_names(vec!["a/b", "c/a/b/", "b"]), correct);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_simplify_dir_dots() {
|
||||
let mut correct = HashSet::new();
|
||||
correct.insert(PathBuf::from("src"));
|
||||
assert_eq!(simplify_dir_names(vec!["src/."]), correct);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_simplify_dir_substring_names() {
|
||||
let mut correct = HashSet::new();
|
||||
correct.insert(PathBuf::from("src"));
|
||||
correct.insert(PathBuf::from("src_v2"));
|
||||
assert_eq!(simplify_dir_names(vec!["src/", "src_v2"]), correct);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_is_a_parent_of() {
|
||||
assert!(is_a_parent_of("/usr", "/usr/andy"));
|
||||
assert!(is_a_parent_of("/usr", "/usr/andy/i/am/descendant"));
|
||||
assert!(!is_a_parent_of("/usr", "/usr/."));
|
||||
assert!(!is_a_parent_of("/usr", "/usr/"));
|
||||
assert!(!is_a_parent_of("/usr", "/usr"));
|
||||
assert!(!is_a_parent_of("/usr/", "/usr"));
|
||||
assert!(!is_a_parent_of("/usr/andy", "/usr"));
|
||||
assert!(!is_a_parent_of("/usr/andy", "/usr/sibling"));
|
||||
assert!(!is_a_parent_of("/usr/folder", "/usr/folder_not_a_child"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_is_a_parent_of_root() {
|
||||
assert!(is_a_parent_of("/", "/usr/andy"));
|
||||
assert!(is_a_parent_of("/", "/usr"));
|
||||
assert!(!is_a_parent_of("/", "/"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_should_ignore_file() {
|
||||
let mut files = HashSet::new();
|
||||
files.insert((10, 20));
|
||||
|
||||
assert!(!should_ignore_file(true, &mut files, Some((0, 0))));
|
||||
|
||||
// New file is not known it will be inserted to the hashmp and should not be ignored
|
||||
assert!(!should_ignore_file(false, &mut files, Some((11, 12))));
|
||||
assert!(files.contains(&(11, 12)));
|
||||
|
||||
// The same file will be ignored the second time
|
||||
assert!(should_ignore_file(false, &mut files, Some((11, 12))));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_should_ignore_file_on_different_device() {
|
||||
let mut files = HashSet::new();
|
||||
files.insert((10, 20));
|
||||
|
||||
// We do not ignore files on the same device
|
||||
assert!(!should_ignore_file(false, &mut files, Some((2, 99))));
|
||||
assert!(!should_ignore_file(true, &mut files, Some((2, 99))));
|
||||
}
|
||||
}
|
||||
@@ -1,128 +0,0 @@
|
||||
use ignore::DirEntry;
|
||||
#[allow(unused_imports)]
|
||||
use std::fs;
|
||||
|
||||
#[cfg(target_family = "unix")]
|
||||
fn get_block_size() -> u64 {
|
||||
// All os specific implementations of MetatdataExt seem to define a block as 512 bytes
|
||||
// https://doc.rust-lang.org/std/os/linux/fs/trait.MetadataExt.html#tymethod.st_blocks
|
||||
512
|
||||
}
|
||||
|
||||
#[cfg(target_family = "unix")]
|
||||
pub fn get_metadata(d: &DirEntry, use_apparent_size: bool) -> Option<(u64, Option<(u64, u64)>)> {
|
||||
use std::os::unix::fs::MetadataExt;
|
||||
match d.metadata() {
|
||||
Ok(md) => {
|
||||
if use_apparent_size {
|
||||
Some((md.len(), Some((md.ino(), md.dev()))))
|
||||
} else {
|
||||
Some((md.blocks() * get_block_size(), Some((md.ino(), md.dev()))))
|
||||
}
|
||||
}
|
||||
Err(_e) => None,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_family = "windows")]
|
||||
pub fn get_metadata(d: &DirEntry, _use_apparent_size: bool) -> Option<(u64, Option<(u64, u64)>)> {
|
||||
// On windows opening the file to get size, file ID and volume can be very
|
||||
// expensive because 1) it causes a few system calls, and more importantly 2) it can cause
|
||||
// windows defender to scan the file.
|
||||
// Therefore we try to avoid doing that for common cases, mainly those of
|
||||
// plain files:
|
||||
|
||||
// The idea is to make do with the file size that we get from the OS for
|
||||
// free as part of iterating a folder. Therefore we want to make sure that
|
||||
// it makes sense to use that free size information:
|
||||
|
||||
// Volume boundaries:
|
||||
// The user can ask us not to cross volume boundaries. If the DirEntry is a
|
||||
// plain file and not a reparse point or other non-trivial stuff, we assume
|
||||
// that the file is located on the same volume as the directory that
|
||||
// contains it.
|
||||
|
||||
// File ID:
|
||||
// This optimization does deprive us of access to a file ID. As a
|
||||
// workaround, we just make one up that hopefully does not collide with real
|
||||
// file IDs.
|
||||
// Hard links: Unresolved. We don't get inode/file index, so hard links
|
||||
// count once for each link. Hopefully they are not too commonly in use on
|
||||
// windows.
|
||||
|
||||
// Size:
|
||||
// We assume (naively?) that for the common cases the free size info is the
|
||||
// same as one would get by doing the expensive thing. Sparse, encrypted and
|
||||
// compressed files are not included in the common cases, as one can image
|
||||
// there being more than view on their size.
|
||||
|
||||
// Savings in orders of magnitude in terms of time, io and cpu have been
|
||||
// observed on hdd, windows 10, some 100Ks files taking up some hundreds of
|
||||
// GBs:
|
||||
// Consistently opening the file: 30 minutes.
|
||||
// With this optimization: 8 sec.
|
||||
|
||||
use std::io;
|
||||
use std::path::Path;
|
||||
use winapi_util::Handle;
|
||||
fn handle_from_path_limited<P: AsRef<Path>>(path: P) -> io::Result<Handle> {
|
||||
use std::fs::OpenOptions;
|
||||
use std::os::windows::fs::OpenOptionsExt;
|
||||
const FILE_READ_ATTRIBUTES: u32 = 0x0080;
|
||||
|
||||
// So, it seems that it does does have to be that expensive to open
|
||||
// files to get their info: Avoiding opening the file with the full
|
||||
// GENERIC_READ is key:
|
||||
|
||||
// https://docs.microsoft.com/en-us/windows/win32/secauthz/generic-access-rights:
|
||||
// "For example, a Windows file object maps the GENERIC_READ bit to the
|
||||
// READ_CONTROL and SYNCHRONIZE standard access rights and to the
|
||||
// FILE_READ_DATA, FILE_READ_EA, and FILE_READ_ATTRIBUTES
|
||||
// object-specific access rights"
|
||||
|
||||
// The flag FILE_READ_DATA seems to be the expensive one, so we'll avoid
|
||||
// that, and a most of the other ones. Simply because it seems that we
|
||||
// don't need them.
|
||||
|
||||
let file = OpenOptions::new()
|
||||
.access_mode(FILE_READ_ATTRIBUTES)
|
||||
.open(path)?;
|
||||
Ok(Handle::from_file(file))
|
||||
}
|
||||
|
||||
fn get_metadata_expensive(d: &DirEntry) -> Option<(u64, Option<(u64, u64)>)> {
|
||||
use winapi_util::file::information;
|
||||
|
||||
let h = handle_from_path_limited(d.path()).ok()?;
|
||||
let info = information(&h).ok()?;
|
||||
|
||||
Some((
|
||||
info.file_size(),
|
||||
Some((info.file_index(), info.volume_serial_number())),
|
||||
))
|
||||
}
|
||||
|
||||
use std::os::windows::fs::MetadataExt;
|
||||
match d.metadata() {
|
||||
Ok(ref md) => {
|
||||
const FILE_ATTRIBUTE_ARCHIVE: u32 = 0x20u32;
|
||||
const FILE_ATTRIBUTE_READONLY: u32 = 0x1u32;
|
||||
const FILE_ATTRIBUTE_HIDDEN: u32 = 0x2u32;
|
||||
const FILE_ATTRIBUTE_SYSTEM: u32 = 0x4u32;
|
||||
const FILE_ATTRIBUTE_NORMAL: u32 = 0x80u32;
|
||||
const FILE_ATTRIBUTE_DIRECTORY: u32 = 0x10u32;
|
||||
|
||||
let attr_filtered = md.file_attributes()
|
||||
& !(FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_SYSTEM);
|
||||
if attr_filtered == FILE_ATTRIBUTE_ARCHIVE
|
||||
|| attr_filtered == FILE_ATTRIBUTE_DIRECTORY
|
||||
|| md.file_attributes() == FILE_ATTRIBUTE_NORMAL
|
||||
{
|
||||
Some((md.len(), None))
|
||||
} else {
|
||||
get_metadata_expensive(&d)
|
||||
}
|
||||
}
|
||||
_ => get_metadata_expensive(&d),
|
||||
}
|
||||
}
|
||||
320
tests/tests.rs
320
tests/tests.rs
@@ -1,320 +0,0 @@
|
||||
use assert_cmd::Command;
|
||||
use std::str;
|
||||
|
||||
mod tests_symlinks;
|
||||
|
||||
// Warning: File sizes differ on both platform and on the format of the disk.
|
||||
/// Copy to /tmp dir - we assume that the formatting of the /tmp partition
|
||||
/// is consistent. If the tests fail your /tmp filesystem probably differs
|
||||
fn copy_test_data(dir: &str) {
|
||||
match Command::new("cp").arg("-r").arg(dir).arg("/tmp/").ok() {
|
||||
Ok(_) => {}
|
||||
Err(err) => {
|
||||
eprintln!("Error copying directory {:?}", err);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// We can at least test the file names are there
|
||||
#[test]
|
||||
pub fn test_basic_output() {
|
||||
let mut cmd = Command::cargo_bin("dust").unwrap();
|
||||
let output = cmd.arg("src/test_dir/").unwrap().stdout;
|
||||
let output = str::from_utf8(&output).unwrap();
|
||||
|
||||
assert!(output.contains(" ┌─┴ "));
|
||||
assert!(output.contains("test_dir "));
|
||||
assert!(output.contains(" ┌─┴ "));
|
||||
assert!(output.contains("many "));
|
||||
assert!(output.contains(" ├── "));
|
||||
assert!(output.contains("hello_file"));
|
||||
assert!(output.contains(" ┌── "));
|
||||
assert!(output.contains("a_file "));
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn test_output_no_bars_means_no_excess_spaces() {
|
||||
let mut cmd = Command::cargo_bin("dust").unwrap();
|
||||
let output = cmd.arg("-b").arg("src/test_dir/").unwrap().stdout;
|
||||
let output = str::from_utf8(&output).unwrap();
|
||||
// If bars are not being shown we don't need to pad the output with spaces
|
||||
assert!(output.contains("many"));
|
||||
assert!(!output.contains("many "));
|
||||
}
|
||||
|
||||
// "windows" result data can vary by host (size seems to be variable by one byte); fix code vs test and re-enable
|
||||
#[cfg_attr(target_os = "windows", ignore)]
|
||||
#[test]
|
||||
pub fn test_main_basic() {
|
||||
copy_test_data("src/test_dir");
|
||||
// -c is no color mode - This makes testing much simpler
|
||||
let mut cmd = Command::cargo_bin("dust").unwrap();
|
||||
let assert = cmd.arg("-c").arg("/tmp/test_dir/").unwrap().stdout;
|
||||
let output = str::from_utf8(&assert).unwrap();
|
||||
assert!(output.contains(&main_output()));
|
||||
}
|
||||
|
||||
#[cfg_attr(target_os = "windows", ignore)]
|
||||
#[test]
|
||||
pub fn test_main_multi_arg() {
|
||||
copy_test_data("src/test_dir");
|
||||
|
||||
let mut cmd = Command::cargo_bin("dust").unwrap();
|
||||
let assert = cmd
|
||||
.arg("-c")
|
||||
.arg("/tmp/test_dir/many/")
|
||||
.arg("/tmp/test_dir")
|
||||
.arg("/tmp/test_dir")
|
||||
.unwrap()
|
||||
.stdout;
|
||||
let output = str::from_utf8(&assert).unwrap();
|
||||
assert!(output.contains(&main_output()));
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
fn main_output() -> String {
|
||||
r#"
|
||||
0B ┌── a_file │░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█ │ 0%
|
||||
4.0K ├── hello_file│██████████████████████████████████████████████ │ 100%
|
||||
4.0K ┌─┴ many │██████████████████████████████████████████████ │ 100%
|
||||
4.0K ┌─┴ test_dir │██████████████████████████████████████████████ │ 100%
|
||||
"#
|
||||
.trim()
|
||||
.to_string()
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
fn main_output() -> String {
|
||||
r#"
|
||||
0B ┌── a_file │ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█ │ 0%
|
||||
4.0K ├── hello_file│ ░░░░░░░░░░░░░░░████████████████ │ 33%
|
||||
8.0K ┌─┴ many │ ███████████████████████████████ │ 67%
|
||||
12K ┌─┴ test_dir │██████████████████████████████████████████████ │ 100%
|
||||
"#
|
||||
.trim()
|
||||
.to_string()
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
fn main_output() -> String {
|
||||
"windows results vary by host".to_string()
|
||||
}
|
||||
|
||||
#[cfg_attr(target_os = "windows", ignore)]
|
||||
#[test]
|
||||
pub fn test_main_long_paths() {
|
||||
copy_test_data("src/test_dir");
|
||||
|
||||
let mut cmd = Command::cargo_bin("dust").unwrap();
|
||||
let assert = cmd
|
||||
.arg("-c")
|
||||
.arg("-p")
|
||||
.arg("/tmp/test_dir/")
|
||||
.unwrap()
|
||||
.stdout;
|
||||
let output = str::from_utf8(&assert).unwrap();
|
||||
assert!(output.contains(&main_output_long_paths()));
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
fn main_output_long_paths() -> String {
|
||||
r#"
|
||||
0B ┌── /tmp/test_dir/many/a_file │░░░░░░░░░░░░░░░░░░░░░░░░░░█ │ 0%
|
||||
4.0K ├── /tmp/test_dir/many/hello_file│███████████████████████████ │ 100%
|
||||
4.0K ┌─┴ /tmp/test_dir/many │███████████████████████████ │ 100%
|
||||
4.0K ┌─┴ /tmp/test_dir │███████████████████████████ │ 100%
|
||||
"#
|
||||
.trim()
|
||||
.to_string()
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
fn main_output_long_paths() -> String {
|
||||
r#"
|
||||
0B ┌── /tmp/test_dir/many/a_file │ ░░░░░░░░░░░░░░░░░░█ │ 0%
|
||||
4.0K ├── /tmp/test_dir/many/hello_file│ ░░░░░░░░░██████████ │ 33%
|
||||
8.0K ┌─┴ /tmp/test_dir/many │ ███████████████████ │ 67%
|
||||
12K ┌─┴ /tmp/test_dir │███████████████████████████ │ 100%
|
||||
"#
|
||||
.trim()
|
||||
.to_string()
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
fn main_output_long_paths() -> String {
|
||||
"windows results vary by host".to_string()
|
||||
}
|
||||
|
||||
#[cfg_attr(target_os = "windows", ignore)]
|
||||
#[test]
|
||||
pub fn test_apparent_size() {
|
||||
copy_test_data("src/test_dir");
|
||||
|
||||
let mut cmd = Command::cargo_bin("dust").unwrap();
|
||||
let assert = cmd.arg("-c").arg("-s").arg("src/test_dir").unwrap().stdout;
|
||||
let output = str::from_utf8(&assert).unwrap();
|
||||
assert!(output.contains(&output_apparent_size()));
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
fn output_apparent_size() -> String {
|
||||
r#"
|
||||
0B ┌── a_file │ ░░░░░░░░░░░░░░░░░░░░░░░█ │ 0%
|
||||
6B ├── hello_file│ ░░░░░░░░░░░░░░░░░░░░░░░█ │ 0%
|
||||
4.0K ┌─┴ many │ ████████████████████████ │ 50%
|
||||
8.0K ┌─┴ test_dir │██████████████████████████████████████████████ │ 100%
|
||||
"#
|
||||
.trim()
|
||||
.to_string()
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
fn output_apparent_size() -> String {
|
||||
r#"
|
||||
0B ┌── a_file │ ░░░░░░░░░░░░░░░░░░░░░░░░░░█ │ 0%
|
||||
6B ├── hello_file│ ░░░░░░░░░░░░░░░░░░░░░░░░░██ │ 3%
|
||||
134B ┌─┴ many │ ███████████████████████████ │ 58%
|
||||
230B ┌─┴ test_dir │██████████████████████████████████████████████ │ 100%
|
||||
"#
|
||||
.trim()
|
||||
.to_string()
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
fn output_apparent_size() -> String {
|
||||
"windows results vary by host".to_string()
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn test_reverse_flag() {
|
||||
let mut cmd = Command::cargo_bin("dust").unwrap();
|
||||
let output = cmd.arg("-c").arg("-r").arg("src/test_dir/").unwrap().stdout;
|
||||
let output = str::from_utf8(&output).unwrap();
|
||||
|
||||
assert!(output.contains(" └─┬ test_dir "));
|
||||
assert!(output.contains(" └─┬ many "));
|
||||
assert!(output.contains(" ├── hello_file"));
|
||||
assert!(output.contains(" └── a_file "));
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn test_d_flag_works() {
|
||||
// We should see the top level directory but not the sub dirs / files:
|
||||
let mut cmd = Command::cargo_bin("dust").unwrap();
|
||||
let output = cmd
|
||||
.arg("-d")
|
||||
.arg("1")
|
||||
.arg("-s")
|
||||
.arg("src/test_dir/")
|
||||
.unwrap()
|
||||
.stdout;
|
||||
let output = str::from_utf8(&output).unwrap();
|
||||
assert!(!output.contains("hello_file"));
|
||||
}
|
||||
|
||||
// Check against directories and files whos names are substrings of each other
|
||||
#[cfg_attr(target_os = "windows", ignore)]
|
||||
#[test]
|
||||
pub fn test_substring_of_names() {
|
||||
copy_test_data("src/test_dir2");
|
||||
|
||||
let mut cmd = Command::cargo_bin("dust").unwrap();
|
||||
let output = cmd.arg("-c").arg("/tmp/test_dir2").unwrap().stdout;
|
||||
let output = str::from_utf8(&output).unwrap();
|
||||
assert!(output.contains(&no_substring_of_names_output()));
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
fn no_substring_of_names_output() -> String {
|
||||
"
|
||||
4.0K ┌── dir_name_clash│ ████████ │ 17%
|
||||
4.0K │ ┌── hello │ ░░░░░░░████████ │ 17%
|
||||
8.0K ├─┴ dir_substring │ ███████████████ │ 33%
|
||||
4.0K │ ┌── hello │ ░░░░░░░████████ │ 17%
|
||||
8.0K ├─┴ dir │ ███████████████ │ 33%
|
||||
24K ┌─┴ test_dir2 │████████████████████████████████████████████ │ 100%
|
||||
"
|
||||
.trim()
|
||||
.into()
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
fn no_substring_of_names_output() -> String {
|
||||
"
|
||||
4.0K ┌── hello │ ███████████████ │ 33%
|
||||
4.0K ┌─┴ dir_substring │ ███████████████ │ 33%
|
||||
4.0K ├── dir_name_clash│ ███████████████ │ 33%
|
||||
4.0K │ ┌── hello │ ███████████████ │ 33%
|
||||
4.0K ├─┴ dir │ ███████████████ │ 33%
|
||||
12K ┌─┴ test_dir2 │████████████████████████████████████████████ │ 100%
|
||||
"
|
||||
.trim()
|
||||
.into()
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
fn no_substring_of_names_output() -> String {
|
||||
"PRs".into()
|
||||
}
|
||||
|
||||
#[cfg_attr(target_os = "windows", ignore)]
|
||||
#[test]
|
||||
pub fn test_unicode_directories() {
|
||||
copy_test_data("src/test_dir3");
|
||||
|
||||
let mut cmd = Command::cargo_bin("dust").unwrap();
|
||||
let output = cmd.arg("-c").arg("/tmp/test_dir3").unwrap().stdout;
|
||||
let output = str::from_utf8(&output).unwrap();
|
||||
assert!(output.contains(&unicode_dir()));
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
fn unicode_dir() -> String {
|
||||
// The way unicode & asian characters are rendered on the terminal should make this line up
|
||||
"
|
||||
0B ┌── 👩.unicode │ █ │ 0%
|
||||
0B ├── ラウトは難しいです!.japan│ █ │ 0%
|
||||
4.0K ┌─┴ test_dir3 │████████████████████████████████ │ 100%
|
||||
"
|
||||
.trim()
|
||||
.into()
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
fn unicode_dir() -> String {
|
||||
"
|
||||
0B ┌── 👩.unicode │ █ │ 0%
|
||||
0B ├── ラウトは難しいです!.japan│ █ │ 0%
|
||||
0B ┌─┴ test_dir3 │ █ │ 0%
|
||||
"
|
||||
.trim()
|
||||
.into()
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
fn unicode_dir() -> String {
|
||||
"".into()
|
||||
}
|
||||
|
||||
// Check against directories and files whos names are substrings of each other
|
||||
#[test]
|
||||
pub fn test_ignore_dir() {
|
||||
let mut cmd = Command::cargo_bin("dust").unwrap();
|
||||
let output = cmd
|
||||
.arg("-c")
|
||||
.arg("-X")
|
||||
.arg("dir_substring")
|
||||
.arg("src/test_dir3")
|
||||
.unwrap()
|
||||
.stdout;
|
||||
let output = str::from_utf8(&output).unwrap();
|
||||
assert!(!output.contains("dir_substring"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn test_with_bad_param() {
|
||||
let mut cmd = Command::cargo_bin("dust").unwrap();
|
||||
let stderr = cmd.arg("-").unwrap().stderr;
|
||||
let stderr = str::from_utf8(&stderr).unwrap();
|
||||
assert!(stderr.contains("Did not have permissions for all directories"));
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
use assert_cmd::Command;
|
||||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
use std::panic;
|
||||
use std::path::PathBuf;
|
||||
use std::str;
|
||||
use tempfile::Builder;
|
||||
use tempfile::TempDir;
|
||||
|
||||
// File sizes differ on both platform and on the format of the disk.
|
||||
// Windows: `ln` is not usually an available command; creation of symbolic links requires special enhanced permissions
|
||||
|
||||
fn build_temp_file(dir: &TempDir) -> PathBuf {
|
||||
let file_path = dir.path().join("notes.txt");
|
||||
let mut file = File::create(&file_path).unwrap();
|
||||
writeln!(file, "I am a temp file").unwrap();
|
||||
file_path
|
||||
}
|
||||
|
||||
#[cfg_attr(target_os = "windows", ignore)]
|
||||
#[test]
|
||||
pub fn test_soft_sym_link() {
|
||||
let dir = Builder::new().tempdir().unwrap();
|
||||
let file = build_temp_file(&dir);
|
||||
let dir_s = dir.path().to_str().unwrap();
|
||||
let file_path_s = file.to_str().unwrap();
|
||||
|
||||
let link_name = dir.path().join("the_link");
|
||||
let link_name_s = link_name.to_str().unwrap();
|
||||
let c = Command::new("ln")
|
||||
.arg("-s")
|
||||
.arg(file_path_s)
|
||||
.arg(link_name_s)
|
||||
.output();
|
||||
assert!(c.is_ok());
|
||||
|
||||
let c = format!(" ┌── {}", link_name_s);
|
||||
let b = format!(" ├── {}", file_path_s);
|
||||
let a = format!("─┴ {}", dir_s);
|
||||
|
||||
let mut cmd = Command::cargo_bin("dust").unwrap();
|
||||
let output = cmd.arg("-p").arg("-c").arg(dir_s).unwrap().stdout;
|
||||
|
||||
let output = str::from_utf8(&output).unwrap();
|
||||
|
||||
assert!(output.contains(a.as_str()));
|
||||
assert!(output.contains(b.as_str()));
|
||||
assert!(output.contains(c.as_str()));
|
||||
}
|
||||
|
||||
#[cfg_attr(target_os = "windows", ignore)]
|
||||
#[test]
|
||||
pub fn test_hard_sym_link() {
|
||||
let dir = Builder::new().tempdir().unwrap();
|
||||
let file = build_temp_file(&dir);
|
||||
let dir_s = dir.path().to_str().unwrap();
|
||||
let file_path_s = file.to_str().unwrap();
|
||||
|
||||
let link_name = dir.path().join("the_link");
|
||||
let link_name_s = link_name.to_str().unwrap();
|
||||
let c = Command::new("ln")
|
||||
.arg(file_path_s)
|
||||
.arg(link_name_s)
|
||||
.output();
|
||||
assert!(c.is_ok());
|
||||
|
||||
let link_output = format!(" ┌── {}", link_name_s);
|
||||
let file_output = format!(" ┌── {}", file_path_s);
|
||||
let dirs_output = format!("─┴ {}", dir_s);
|
||||
|
||||
let mut cmd = Command::cargo_bin("dust").unwrap();
|
||||
let output = cmd.arg("-p").arg("-c").arg(dir_s).unwrap().stdout;
|
||||
|
||||
// Because this is a hard link the file and hard link look identical. Therefore
|
||||
// we cannot guarantee which version will appear first.
|
||||
let output = str::from_utf8(&output).unwrap();
|
||||
assert!(output.contains(dirs_output.as_str()));
|
||||
assert!(output.contains(link_output.as_str()) || output.contains(file_output.as_str()));
|
||||
}
|
||||
|
||||
#[cfg_attr(target_os = "windows", ignore)]
|
||||
#[test]
|
||||
pub fn test_recursive_sym_link() {
|
||||
let dir = Builder::new().tempdir().unwrap();
|
||||
let dir_s = dir.path().to_str().unwrap();
|
||||
|
||||
let link_name = dir.path().join("the_link");
|
||||
let link_name_s = link_name.to_str().unwrap();
|
||||
|
||||
let c = Command::new("ln")
|
||||
.arg("-s")
|
||||
.arg(dir_s)
|
||||
.arg(link_name_s)
|
||||
.output();
|
||||
assert!(c.is_ok());
|
||||
|
||||
let a = format!("─┬ {}", dir_s);
|
||||
let b = format!(" └── {}", link_name_s);
|
||||
|
||||
let mut cmd = Command::cargo_bin("dust").unwrap();
|
||||
let output = cmd.arg("-p").arg("-c").arg("-r").arg(dir_s).unwrap().stdout;
|
||||
|
||||
let output = str::from_utf8(&output).unwrap();
|
||||
assert!(output.contains(a.as_str()));
|
||||
assert!(output.contains(b.as_str()));
|
||||
}
|
||||
Reference in New Issue
Block a user