571 Commits

Author SHA1 Message Date
andy.boot
ed6a8d0462 Revert tests
Revert symlink tests to their old form - No mix of arg and args & a
comment explaining why we need a large width.
2022-08-20 11:09:56 +01:00
andy.boot
4cef6aaa84 Refactor: init_color function
Refactor function so windows & linux are forced to have same signature
instead of 2 different functions
2022-08-20 11:09:56 +01:00
andy.boot
d477145694 Tests refactor: Neaten test 2022-08-20 11:09:56 +01:00
andy.boot
dc5b7b2c2e Comment: Update comment text 2022-08-20 11:09:56 +01:00
andy.boot
cf5ebd76fe Refactor: Reintroduce local variable 2022-08-20 11:09:56 +01:00
andy.boot
fc548919c5 Refactor: Move filter by file type to new file 2022-08-20 11:09:56 +01:00
andy.boot
4b4bca52d9 Rename variable
Better name, this represents the percent bars just 'percent' is vague
2022-08-20 11:09:56 +01:00
andy.boot
2a9d545c3c Style: Remove ColorState enum, revert init_color
Booleans are simpler and easier to work with.

Revert init_color to its earlier state as it is easier to understand
2022-08-20 11:09:56 +01:00
andy.boot
20cc5cf7e0 Clippy: Fix clippy 2022-08-20 11:09:56 +01:00
Nathan West
5fcc45efbe Use correct error code type 2022-08-20 10:50:46 +01:00
Nathan West
282f6d314d get_new_root no longer panics if there are 0 nodes 2022-08-20 10:50:46 +01:00
Nathan West
c36ca33fe9 Lots of code cleanup
- Try to use iterator adapters and collect in various places, where possible. This especially benefits draw_it.
- Try to use `.map` and other similar methods on Options and Results, where possible
- Replaced nearly all clones with reference-based equivalents
- Summarizing nodes by file extension is now much more efficient
- PartialOrd and PartialEq implementations now agree
- Replace #[cfg(...)] function definitions with simpler if cfg!(...) equivelents
- Simplify CLI Values handling by taking advantage of Values::default
- Various spelling corrections in comments
- Add `ColorState` enum to replace bool, for clarity
- Fix tests that break under some detected terminal widths when paths are long
- Use sort_by instead of (sort, reverse)
- Use new `ExtensionNode` struct internally to simplify extension aggregation code
2022-08-20 10:50:46 +01:00
andy.boot
34ba99af2a Tests: Check stderr is empty in test_flags
For each test_flag test using the build_command helper method, check
that stderr is empty
2022-08-19 10:43:24 +01:00
andy.boot
2713445ad0 Fix: Permissions
Stop incorrect reporting of "Did not have permissions" this would
happen where dust is called with a file instead of a directory.

https://github.com/bootandy/dust/issues/241

todo: add test
2022-08-19 10:43:24 +01:00
andy.boot
b62f35291d Fix: Remove first space char
Before we assumed 5 chars for printing the size of a node. This change
allows us to check if we need 5 chars or if we can manage with 4 which
may save us a character.

(1023B = 5 chars, 1.2K = 4 chars)

Note: Mac test runners create very long filenames in tmp directories. To
fix this we must either
1) Tell the terminal it has a very wide width
2) Duplicate the code to reduce the size of the filename (add .. at the
   end).

This commit changes from (2) to (1)
2022-08-19 10:41:59 +01:00
andy.boot
a7fbcb8156 Refactor: Simplify get_pretty_size
Remove the constant '5' used in format. Now all paths use
num_chars_needed_on_left_most instead.
2022-08-19 10:41:59 +01:00
andy.boot
a7120b949c Tests: Add test to verify skip-total flag 2022-08-18 15:22:10 +01:00
andy.boot
812e1e3c53 Feature: Add skip-total flag
Flag to not include the last line containing totals of the output tree
2022-08-18 15:22:10 +01:00
andy.boot
4eb3f29565 Tests: Predictable iteration order allows stricter
Now files are iterated thru in a preditermined order we can tighten the
boundaries of the test_hard_sym_link test.

Link will not be displayed, only the file name
2022-08-18 13:39:01 +01:00
andy.boot
d64092d8a1 Fix: Predictable iteration order
Sort the Node objects so that duplicate inodes appear in a predictable
order.

Include new sort_by_inode method because this is notably quicker than
sorting by size & name as defined in the nodes.rs file.
2022-08-18 13:16:09 +01:00
andy.boot
77750c8149 Update README.md 2022-08-18 13:15:05 +01:00
andy.boot
b9386cd39e Fix: Increase Stack size
Low stack size could result in a stack overflow exception if traversing
very highly nested directories.

This makes core-dumps less likely but will not completely remove the
risk

example for creating directories:
mkdir -p $(for i in {1..5000}; do echo -n "qwe/"; done)

original issue:
https://github.com/bootandy/dust/issues/197
2022-08-15 14:05:24 +01:00
andy.boot
17112b09cc Clippy: Remove un-needed return 2022-08-15 12:26:47 +01:00
andy.boot
c5adff5348 Clippy: Remove un-needed return 2022-08-15 12:26:47 +01:00
somehowchris
ad2e52e211 perf: use lto, strip and codegen profile settings for perf opt 2022-08-15 11:56:46 +01:00
andy.boot
164bec71a3 Update libs 2022-07-14 09:42:45 +01:00
andy.boot
11b5c7227f New Version 2022-07-14 08:53:45 +01:00
andy.boot
fc70f9ba30 Rename variable 2022-07-13 09:38:21 +01:00
andy.boot
a00d1f0719 Fix: Allow -n to be used with -d
Allow -n for number_of_lines to be used with -d 'max depth'

Remove depth specific functions, the job is now handled by the mainline

Add depth as a field onto the Node object.
2022-07-13 09:38:21 +01:00
andy.boot
c4ea7815f8 Refactor: tweak utils function
Refactor simplify_dir_names to make it more readable
2022-07-01 12:04:31 +01:00
dependabot[bot]
afc36a633f Bump regex from 1.5.4 to 1.5.5
Bumps [regex](https://github.com/rust-lang/regex) from 1.5.4 to 1.5.5.
- [Release notes](https://github.com/rust-lang/regex/releases)
- [Changelog](https://github.com/rust-lang/regex/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/regex/compare/1.5.4...1.5.5)

---
updated-dependencies:
- dependency-name: regex
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-07 09:00:43 +01:00
unknown
7275b273d4 Fix archive/directory check in platform.rs 2022-05-02 12:11:22 +01:00
andy.boot
a3e59f9c25 Update README.md 2022-03-05 22:02:09 +00:00
Adam Stephens
48bf656123 add aarch64 gnu and musl cross targets 2022-02-27 10:09:38 +00:00
andy.boot
fabb27908d Increment version 2022-02-26 11:47:06 +00:00
andy.boot
52aeeebe1f Improve help text 2022-02-26 11:47:06 +00:00
andy.boot
1e27288ec2 Fix test: Remove unwanted mod
This line caused the test_symlinks files to be run twice.
2022-02-26 11:10:26 +00:00
andy.boot
9f4a5daee6 Update library: Clap
Required several changes to main.rs as v3 had breaking changes.
2022-02-26 11:10:26 +00:00
andy.boot
27f0a015ef Update cargo packages 2022-02-26 11:10:26 +00:00
andy.boot
20d89bef91 Neaten code 2022-02-26 09:58:47 +00:00
andy.boot
469e6d0a69 Fix: Bug: names may be shortened unnecessarily
The code calculating the width of a row to use vs the width of the
terminal wasn't quite right.

If we had 2 long filepaths one at the top of the dir tree and one at the
bottom the old code would shorten both equally. This doesn't make sense
as the one at the shallowest part of the tree would have used less
screen real estate and so should show a longer part of the filepath.
2022-02-26 09:58:47 +00:00
andy.boot
2d58609d54 Fix: Add assert for low terminal width
If terminal is not wide enought to print text, then print an error
message

https://github.com/bootandy/dust/issues/204
2022-01-02 22:41:02 +00:00
andy.boot
109a0b90d4 Update help text: number_of_lines
Remove note about 'height' and '-h being help' because it confused
people.

Add text to explain default height is terminal height - 10
https://github.com/bootandy/dust/issues/201
2022-01-02 22:41:02 +00:00
andy.boot
ab67c1a50e Update help text: Add note for -c about watch
Issue was raised about using dust with watch. The solution is to use
watch --color dust or watch dust -c

https://github.com/bootandy/dust/issues/205
2022-01-02 22:41:02 +00:00
Sourajyoti Basak
6a34b52d15 docs(readme): add pacstall installation method 2021-12-21 10:07:28 +00:00
Gustavobb
f708305190 Feature: Implement ISO output 2021-11-20 12:13:30 +00:00
andy.boot
2749f56b7a Tests: Fix test on mac (hack)
For some unknown reason mac takes offence to searching for
'test_dir_unicode'. 'test_dir_hidden' seems to work fine.

This isn't a proper fix as I've just hacked round the problem. Ideally
I'd need a mac user to do some investigation.
2021-11-20 12:05:48 +00:00
andy.boot
d983175189 Cleanup: Vec -> &[]. Remove println. 2021-10-24 14:05:14 +01:00
andy.boot
4b3dc3988d Tests: Move test apparent size to exact_output
Because apparent_size uses the test files created in /tmp it needs to be
in the test_exact_output where those files are copied. Otherwise the files
may not be there when the test is run.
2021-10-24 14:05:14 +01:00
andy.boot
fa4405b58b Cleanup: Remove unused comment
This was fixed a few commits ago
2021-10-24 14:05:14 +01:00