Skip to content

Commit d328df6

Browse files
CopilotKSXGitHub
andcommitted
chore: merge master branch updates (USAGE.md, usage_md module, sync tests)
Co-authored-by: KSXGitHub <11488886+KSXGitHub@users.noreply.github.com>
1 parent 3cc45c5 commit d328df6

12 files changed

Lines changed: 721 additions & 3 deletions

File tree

Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ include = [
2525
"/tests",
2626
"/Cargo.toml",
2727
"/README.md",
28+
"/USAGE.md",
2829
"/LICENSE",
2930
]
3031

@@ -42,6 +43,11 @@ name = "pdu-completions"
4243
path = "cli/completions.rs"
4344
required-features = ["cli-completions"]
4445

46+
[[bin]]
47+
name = "pdu-usage-md"
48+
path = "cli/usage_md.rs"
49+
required-features = ["cli"]
50+
4551
[features]
4652
default = ["cli"]
4753
json = ["serde/derive", "serde_json"]

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,15 @@ The benchmark was generated by [a GitHub Workflow](https://github.com/KSXGitHub/
6464
* Do not differentiate filesystem: Mounted folders are counted as normal folders.
6565
* The runtime is optimized at the expense of binary size.
6666

67+
## Usage
68+
69+
See [USAGE.md](./USAGE.md) for the full help text.
70+
6771
## Development
6872

6973
### Prerequisites
7074

71-
* [`cargo`](github.com/rust-lang/cargo)
75+
* [`cargo`](https://github.com/rust-lang/cargo)
7276

7377
### Test
7478

USAGE.md

Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
# Usage
2+
3+
```sh
4+
pdu [OPTIONS] [FILES]...
5+
```
6+
7+
## Arguments
8+
9+
* `[FILES]...`: List of files and/or directories.
10+
11+
## Options
12+
13+
<a id="json-input" name="json-input"></a>
14+
### `--json-input`
15+
16+
Read JSON data from stdin.
17+
18+
<a id="json-output" name="json-output"></a>
19+
### `--json-output`
20+
21+
Print JSON data instead of an ASCII chart.
22+
23+
<a id="option-b" name="option-b"></a><a id="bytes-format" name="bytes-format"></a>
24+
### `--bytes-format`
25+
26+
* _Aliases:_ `-b`.
27+
* _Default:_ `metric`.
28+
* _Choices:_
29+
- `plain`: Display plain number of bytes without units
30+
- `metric`: Use metric scale, i.e. 1K = 1000B, 1M = 1000K, and so on
31+
- `binary`: Use binary scale, i.e. 1K = 1024B, 1M = 1024K, and so on
32+
33+
How to display the numbers of bytes.
34+
35+
<a id="option-H" name="option-H"></a><a id="deduplicate-hardlinks" name="deduplicate-hardlinks"></a><a id="detect-links" name="detect-links"></a><a id="dedupe-links" name="dedupe-links"></a>
36+
### `--deduplicate-hardlinks`
37+
38+
* _Aliases:_ `-H`, `--detect-links`, `--dedupe-links`.
39+
40+
Detect and subtract the sizes of hardlinks from their parent directory totals.
41+
42+
<a id="top-down" name="top-down"></a>
43+
### `--top-down`
44+
45+
Print the tree top-down instead of bottom-up.
46+
47+
<a id="align-right" name="align-right"></a>
48+
### `--align-right`
49+
50+
Set the root of the bars to the right.
51+
52+
<a id="option-q" name="option-q"></a><a id="quantity" name="quantity"></a>
53+
### `--quantity`
54+
55+
* _Aliases:_ `-q`.
56+
* _Default:_ `block-size`.
57+
* _Choices:_
58+
- `apparent-size`: Measure apparent sizes
59+
- `block-size`: Measure block sizes (block-count * 512B)
60+
- `block-count`: Count numbers of blocks
61+
62+
Aspect of the files/directories to be measured.
63+
64+
<a id="option-d" name="option-d"></a><a id="max-depth" name="max-depth"></a><a id="depth" name="depth"></a>
65+
### `--max-depth`
66+
67+
* _Aliases:_ `-d`, `--depth`.
68+
* _Default:_ `10`.
69+
70+
Maximum depth to display the data. Could be either "inf" or a positive integer.
71+
72+
<a id="option-w" name="option-w"></a><a id="total-width" name="total-width"></a><a id="width" name="width"></a>
73+
### `--total-width`
74+
75+
* _Aliases:_ `-w`, `--width`.
76+
77+
Width of the visualization.
78+
79+
<a id="column-width" name="column-width"></a>
80+
### `--column-width`
81+
82+
Maximum widths of the tree column and width of the bar column.
83+
84+
<a id="option-m" name="option-m"></a><a id="min-ratio" name="min-ratio"></a>
85+
### `--min-ratio`
86+
87+
* _Aliases:_ `-m`.
88+
* _Default:_ `0.01`.
89+
90+
Minimal size proportion required to appear.
91+
92+
<a id="no-sort" name="no-sort"></a>
93+
### `--no-sort`
94+
95+
Do not sort the branches in the tree.
96+
97+
<a id="option-s" name="option-s"></a><a id="silent-errors" name="silent-errors"></a><a id="no-errors" name="no-errors"></a>
98+
### `--silent-errors`
99+
100+
* _Aliases:_ `-s`, `--no-errors`.
101+
102+
Prevent filesystem error messages from appearing in stderr.
103+
104+
<a id="option-p" name="option-p"></a><a id="progress" name="progress"></a>
105+
### `--progress`
106+
107+
* _Aliases:_ `-p`.
108+
109+
Report progress being made at the expense of performance.
110+
111+
<a id="threads" name="threads"></a>
112+
### `--threads`
113+
114+
* _Default:_ `auto`.
115+
116+
Set the maximum number of threads to spawn. Could be either "auto", "max", or a positive integer.
117+
118+
<a id="omit-json-shared-details" name="omit-json-shared-details"></a>
119+
### `--omit-json-shared-details`
120+
121+
Do not output `.shared.details` in the JSON output.
122+
123+
<a id="omit-json-shared-summary" name="omit-json-shared-summary"></a>
124+
### `--omit-json-shared-summary`
125+
126+
Do not output `.shared.summary` in the JSON output.
127+
128+
<a id="option-h" name="option-h"></a><a id="help" name="help"></a>
129+
### `--help`
130+
131+
* _Aliases:_ `-h`.
132+
133+
Print help.
134+
135+
<a id="option-V" name="option-V"></a><a id="version" name="version"></a>
136+
### `--version`
137+
138+
* _Aliases:_ `-V`.
139+
140+
Print version.
141+
142+
## Examples
143+
144+
### Show disk usage chart of current working directory
145+
146+
```sh
147+
pdu
148+
```
149+
150+
### Show disk usage chart of a single file or directory
151+
152+
```sh
153+
pdu path/to/file/or/directory
154+
```
155+
156+
### Compare disk usages of multiple files and/or directories
157+
158+
```sh
159+
pdu file.txt dir/
160+
```
161+
162+
### Show chart in apparent sizes instead of block sizes
163+
164+
```sh
165+
pdu --quantity=apparent-size
166+
```
167+
168+
### Detect and subtract the sizes of hardlinks from their parent nodes
169+
170+
```sh
171+
pdu --deduplicate-hardlinks
172+
```
173+
174+
### Show sizes in plain numbers instead of metric units
175+
176+
```sh
177+
pdu --bytes-format=plain
178+
```
179+
180+
### Show sizes in base 2¹⁰ units (binary) instead of base 10³ units (metric)
181+
182+
```sh
183+
pdu --bytes-format=binary
184+
```
185+
186+
### Show disk usage chart of all entries regardless of size
187+
188+
```sh
189+
pdu --min-ratio=0
190+
```
191+
192+
### Only show disk usage chart of entries whose size is at least 5% of total
193+
194+
```sh
195+
pdu --min-ratio=0.05
196+
```
197+
198+
### Show disk usage data as JSON instead of chart
199+
200+
```sh
201+
pdu --min-ratio=0 --max-depth=inf --json-output | jq
202+
```
203+
204+
### Visualize existing JSON representation of disk usage data
205+
206+
```sh
207+
pdu --json-input < disk-usage.json
208+
```

cli/usage_md.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
use parallel_disk_usage::usage_md::render_usage_md;
2+
3+
fn main() {
4+
println!("{}", render_usage_md().trim_end());
5+
}

exports/long.help

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
Summarize disk usage of the set of files, recursively for directories.
2+
3+
Copyright: Apache-2.0 © 2021 Hoàng Văn Khải <https://github.com/KSXGitHub/>
4+
Sponsor: https://github.com/sponsors/KSXGitHub
5+
6+
Usage: pdu [OPTIONS] [FILES]...
7+
8+
Arguments:
9+
[FILES]...
10+
List of files and/or directories
11+
12+
Options:
13+
--json-input
14+
Read JSON data from stdin
15+
16+
--json-output
17+
Print JSON data instead of an ASCII chart
18+
19+
-b, --bytes-format <BYTES_FORMAT>
20+
How to display the numbers of bytes
21+
22+
Possible values:
23+
- plain: Display plain number of bytes without units
24+
- metric: Use metric scale, i.e. 1K = 1000B, 1M = 1000K, and so on
25+
- binary: Use binary scale, i.e. 1K = 1024B, 1M = 1024K, and so on
26+
27+
[default: metric]
28+
29+
-H, --deduplicate-hardlinks
30+
Detect and subtract the sizes of hardlinks from their parent directory totals
31+
32+
[aliases: --detect-links, --dedupe-links]
33+
34+
--top-down
35+
Print the tree top-down instead of bottom-up
36+
37+
--align-right
38+
Set the root of the bars to the right
39+
40+
-q, --quantity <QUANTITY>
41+
Aspect of the files/directories to be measured
42+
43+
Possible values:
44+
- apparent-size: Measure apparent sizes
45+
- block-size: Measure block sizes (block-count * 512B)
46+
- block-count: Count numbers of blocks
47+
48+
[default: block-size]
49+
50+
-d, --max-depth <MAX_DEPTH>
51+
Maximum depth to display the data. Could be either "inf" or a positive integer
52+
53+
[default: 10]
54+
[aliases: --depth]
55+
56+
-w, --total-width <TOTAL_WIDTH>
57+
Width of the visualization
58+
59+
[aliases: --width]
60+
61+
--column-width <TREE_WIDTH> <BAR_WIDTH>
62+
Maximum widths of the tree column and width of the bar column
63+
64+
-m, --min-ratio <MIN_RATIO>
65+
Minimal size proportion required to appear
66+
67+
[default: 0.01]
68+
69+
--no-sort
70+
Do not sort the branches in the tree
71+
72+
-s, --silent-errors
73+
Prevent filesystem error messages from appearing in stderr
74+
75+
[aliases: --no-errors]
76+
77+
-p, --progress
78+
Report progress being made at the expense of performance
79+
80+
--threads <THREADS>
81+
Set the maximum number of threads to spawn. Could be either "auto", "max", or a positive integer
82+
83+
[default: auto]
84+
85+
--omit-json-shared-details
86+
Do not output `.shared.details` in the JSON output
87+
88+
--omit-json-shared-summary
89+
Do not output `.shared.summary` in the JSON output
90+
91+
-h, --help
92+
Print help (see a summary with '-h')
93+
94+
-V, --version
95+
Print version
96+
97+
Examples:
98+
Show disk usage chart of current working directory
99+
$ pdu
100+
101+
Show disk usage chart of a single file or directory
102+
$ pdu path/to/file/or/directory
103+
104+
Compare disk usages of multiple files and/or directories
105+
$ pdu file.txt dir/
106+
107+
Show chart in apparent sizes instead of block sizes
108+
$ pdu --quantity=apparent-size
109+
110+
Detect and subtract the sizes of hardlinks from their parent nodes
111+
$ pdu --deduplicate-hardlinks
112+
113+
Show sizes in plain numbers instead of metric units
114+
$ pdu --bytes-format=plain
115+
116+
Show sizes in base 2¹⁰ units (binary) instead of base 10³ units (metric)
117+
$ pdu --bytes-format=binary
118+
119+
Show disk usage chart of all entries regardless of size
120+
$ pdu --min-ratio=0
121+
122+
Only show disk usage chart of entries whose size is at least 5% of total
123+
$ pdu --min-ratio=0.05
124+
125+
Show disk usage data as JSON instead of chart
126+
$ pdu --min-ratio=0 --max-depth=inf --json-output | jq
127+
128+
Visualize existing JSON representation of disk usage data
129+
$ pdu --json-input < disk-usage.json

0 commit comments

Comments
 (0)