-
-
Notifications
You must be signed in to change notification settings - Fork 19
docs: cli usage #324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
docs: cli usage #324
Changes from 45 commits
Commits
Show all changes
53 commits
Select commit
Hold shift + click to select a range
3b26ddd
Initial plan
Copilot b83af13
docs: add CLI usage documentation and sync_help tests
Copilot d17b9c1
fix: restrict sync_help tests to unix only
Copilot 81b8f0d
feat: parse long.help to generate structured USAGE.md
Copilot 18be173
refactor: parse flags/aliases/examples properly; fix Clippy warnings;…
Copilot 8dce0c9
refactor(usage_md): heading-based options, periods on descriptions, i…
Copilot b30f626
fix: remove redundant .iter() on Vec in render_option_item
Copilot 991ac44
refactor(usage_md): move render to src/usage_md, use Args::command(),…
Copilot 40f6184
refactor(usage_md): address review comments - iterator return type, C…
Copilot 30c6e42
refactor(usage_md): use strip_prefix consistently for anchor id gener…
Copilot d92ac00
refactor(usage_md): rewrite render to use clap introspection API
Copilot 9632a78
fix(lib): move pub mod usage_md into the cfg(feature = \"cli\") group
Copilot c4b5c02
refactor(usage_md): address all review comments and fix CI failures
Copilot de881ba
docs: remove unnecessary text
KSXGitHub 73077f4
refactor: undo
KSXGitHub 8e17223
docs: remove unnecessary documentation
KSXGitHub 55655c8
style: imports together
KSXGitHub 08a13a3
style: use shadowing
KSXGitHub 94bf09c
refactor: simplify
KSXGitHub 01f0676
refactor: correct a function name
KSXGitHub d5f4d65
refactor: stop using short variable
KSXGitHub 96062b0
refactor: remove temporary `Vec`
KSXGitHub 055dad0
refactor: remove duplicated `to_string_lossy`
KSXGitHub 8316641
refactor: rename a variable
KSXGitHub f4d6360
refactor: unabbreviate a variable
KSXGitHub fc15472
refactor: unabbreviate a variable
KSXGitHub 54fad48
refactor: unabbreviate some variables
KSXGitHub 22236c8
refactor: unabbreviate some variables
KSXGitHub a6adb98
refactor: unabbreviate a variable
KSXGitHub c642f25
refactor: unabbreviate a variable
KSXGitHub 2d745ae
refactor(usage_md): extract helper functions, fix var names, use curr…
Copilot 91a452f
refactor: simplify
KSXGitHub 5ecaea3
refactor: shorten some variable names
KSXGitHub c7895dd
refactor: prefer turbo fish
KSXGitHub 691f321
refactor: remove unnecessary bindings
KSXGitHub 2309236
refactor: stop using temporary `Vec`
KSXGitHub 46b9109
refactor: make `out: &String` the first arg
KSXGitHub 9917068
refactor: remove potential panic
KSXGitHub 8036fdf
refactor: remove unnecessary allocation
KSXGitHub 0fa4aa8
fix(docs/usage): stop concatenating
KSXGitHub c74bc7f
fix(docs): unnecessary comments
KSXGitHub 5fc9f28
fix: required positional args use angle brackets; use get_action() to…
Copilot 03ec521
refactor: reduce allocation
KSXGitHub d2b6169
feat(docs): still show default of `"true"`
KSXGitHub c178b5d
refactor: replace the brittle string replacement
KSXGitHub 32628c6
refactor: remove unused link
KSXGitHub bf66a60
fix: strip trailing whitespace from help exports and normalize in tests
Copilot 22fd0af
refactor: use `pipe`
KSXGitHub 38b2369
test: remove unnecessary trimming
KSXGitHub ef37654
refactor: use macro
KSXGitHub b801758
refactor: rename a test
KSXGitHub b516907
chore(cargo): include `USAGE.md`
KSXGitHub 05e0285
refactor: split the tests
KSXGitHub File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,208 @@ | ||
| # Usage | ||
|
|
||
| ```sh | ||
| pdu [OPTIONS] [FILES]... | ||
| ``` | ||
|
|
||
| ## Arguments | ||
|
|
||
| * `[FILES]...`: List of files and/or directories. | ||
|
|
||
| ## Options | ||
|
|
||
| <a id="json-input" name="json-input"></a> | ||
| ### `--json-input` | ||
|
|
||
| Read JSON data from stdin. | ||
|
|
||
| <a id="json-output" name="json-output"></a> | ||
| ### `--json-output` | ||
|
|
||
| Print JSON data instead of an ASCII chart. | ||
|
|
||
| <a id="option-b" name="option-b"></a><a id="bytes-format" name="bytes-format"></a> | ||
| ### `--bytes-format` | ||
|
|
||
| * _Aliases:_ `-b`. | ||
| * _Default:_ `metric`. | ||
| * _Choices:_ | ||
| - `plain`: Display plain number of bytes without units | ||
| - `metric`: Use metric scale, i.e. 1K = 1000B, 1M = 1000K, and so on | ||
| - `binary`: Use binary scale, i.e. 1K = 1024B, 1M = 1024K, and so on | ||
|
|
||
| How to display the numbers of bytes. | ||
|
|
||
| <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> | ||
| ### `--deduplicate-hardlinks` | ||
|
KSXGitHub marked this conversation as resolved.
|
||
|
|
||
| * _Aliases:_ `-H`, `--detect-links`, `--dedupe-links`. | ||
|
|
||
| Detect and subtract the sizes of hardlinks from their parent directory totals. | ||
|
|
||
| <a id="top-down" name="top-down"></a> | ||
| ### `--top-down` | ||
|
|
||
| Print the tree top-down instead of bottom-up. | ||
|
|
||
| <a id="align-right" name="align-right"></a> | ||
| ### `--align-right` | ||
|
|
||
| Set the root of the bars to the right. | ||
|
|
||
| <a id="option-q" name="option-q"></a><a id="quantity" name="quantity"></a> | ||
| ### `--quantity` | ||
|
|
||
| * _Aliases:_ `-q`. | ||
| * _Default:_ `block-size`. | ||
| * _Choices:_ | ||
| - `apparent-size`: Measure apparent sizes | ||
| - `block-size`: Measure block sizes (block-count * 512B) | ||
| - `block-count`: Count numbers of blocks | ||
|
|
||
| Aspect of the files/directories to be measured. | ||
|
|
||
| <a id="option-d" name="option-d"></a><a id="max-depth" name="max-depth"></a><a id="depth" name="depth"></a> | ||
| ### `--max-depth` | ||
|
|
||
| * _Aliases:_ `-d`, `--depth`. | ||
| * _Default:_ `10`. | ||
|
|
||
| Maximum depth to display the data. Could be either "inf" or a positive integer. | ||
|
|
||
| <a id="option-w" name="option-w"></a><a id="total-width" name="total-width"></a><a id="width" name="width"></a> | ||
| ### `--total-width` | ||
|
|
||
| * _Aliases:_ `-w`, `--width`. | ||
|
|
||
| Width of the visualization. | ||
|
|
||
| <a id="column-width" name="column-width"></a> | ||
| ### `--column-width` | ||
|
|
||
| Maximum widths of the tree column and width of the bar column. | ||
|
|
||
| <a id="option-m" name="option-m"></a><a id="min-ratio" name="min-ratio"></a> | ||
| ### `--min-ratio` | ||
|
|
||
| * _Aliases:_ `-m`. | ||
| * _Default:_ `0.01`. | ||
|
|
||
| Minimal size proportion required to appear. | ||
|
|
||
| <a id="no-sort" name="no-sort"></a> | ||
| ### `--no-sort` | ||
|
|
||
| Do not sort the branches in the tree. | ||
|
|
||
| <a id="option-s" name="option-s"></a><a id="silent-errors" name="silent-errors"></a><a id="no-errors" name="no-errors"></a> | ||
| ### `--silent-errors` | ||
|
|
||
| * _Aliases:_ `-s`, `--no-errors`. | ||
|
|
||
| Prevent filesystem error messages from appearing in stderr. | ||
|
|
||
| <a id="option-p" name="option-p"></a><a id="progress" name="progress"></a> | ||
| ### `--progress` | ||
|
|
||
| * _Aliases:_ `-p`. | ||
|
|
||
| Report progress being made at the expense of performance. | ||
|
|
||
| <a id="threads" name="threads"></a> | ||
| ### `--threads` | ||
|
|
||
| * _Default:_ `auto`. | ||
|
|
||
| Set the maximum number of threads to spawn. Could be either "auto", "max", or a positive integer. | ||
|
|
||
| <a id="omit-json-shared-details" name="omit-json-shared-details"></a> | ||
| ### `--omit-json-shared-details` | ||
|
|
||
| Do not output `.shared.details` in the JSON output. | ||
|
|
||
| <a id="omit-json-shared-summary" name="omit-json-shared-summary"></a> | ||
| ### `--omit-json-shared-summary` | ||
|
|
||
| Do not output `.shared.summary` in the JSON output. | ||
|
|
||
| <a id="option-h" name="option-h"></a><a id="help" name="help"></a> | ||
| ### `--help` | ||
|
|
||
| * _Aliases:_ `-h`. | ||
|
|
||
| Print help. | ||
|
|
||
| <a id="option-V" name="option-V"></a><a id="version" name="version"></a> | ||
| ### `--version` | ||
|
|
||
| * _Aliases:_ `-V`. | ||
|
|
||
| Print version. | ||
|
|
||
| ## Examples | ||
|
|
||
| ### Show disk usage chart of current working directory | ||
|
|
||
| ```sh | ||
| pdu | ||
| ``` | ||
|
|
||
| ### Show disk usage chart of a single file or directory | ||
|
|
||
| ```sh | ||
| pdu path/to/file/or/directory | ||
| ``` | ||
|
|
||
| ### Compare disk usages of multiple files and/or directories | ||
|
|
||
| ```sh | ||
| pdu file.txt dir/ | ||
| ``` | ||
|
|
||
| ### Show chart in apparent sizes instead of block sizes | ||
|
|
||
| ```sh | ||
| pdu --quantity=apparent-size | ||
| ``` | ||
|
|
||
| ### Detect and subtract the sizes of hardlinks from their parent nodes | ||
|
|
||
| ```sh | ||
| pdu --deduplicate-hardlinks | ||
| ``` | ||
|
|
||
| ### Show sizes in plain numbers instead of metric units | ||
|
|
||
| ```sh | ||
| pdu --bytes-format=plain | ||
| ``` | ||
|
|
||
| ### Show sizes in base 2¹⁰ units (binary) instead of base 10³ units (metric) | ||
|
|
||
| ```sh | ||
| pdu --bytes-format=binary | ||
| ``` | ||
|
|
||
| ### Show disk usage chart of all entries regardless of size | ||
|
|
||
| ```sh | ||
| pdu --min-ratio=0 | ||
| ``` | ||
|
|
||
| ### Only show disk usage chart of entries whose size is at least 5% of total | ||
|
|
||
| ```sh | ||
| pdu --min-ratio=0.05 | ||
| ``` | ||
|
|
||
| ### Show disk usage data as JSON instead of chart | ||
|
|
||
| ```sh | ||
| pdu --min-ratio=0 --max-depth=inf --json-output | jq | ||
| ``` | ||
|
|
||
| ### Visualize existing JSON representation of disk usage data | ||
|
|
||
| ```sh | ||
| pdu --json-input < disk-usage.json | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| use parallel_disk_usage::usage_md::render_usage_md; | ||
|
|
||
| fn main() { | ||
| println!("{}", render_usage_md().trim_end()); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,129 @@ | ||
| Summarize disk usage of the set of files, recursively for directories. | ||
|
|
||
| Copyright: Apache-2.0 © 2021 Hoàng Văn Khải <https://github.com/KSXGitHub/> | ||
| Sponsor: https://github.com/sponsors/KSXGitHub | ||
|
|
||
| Usage: pdu [OPTIONS] [FILES]... | ||
|
|
||
| Arguments: | ||
| [FILES]... | ||
| List of files and/or directories | ||
|
|
||
| Options: | ||
| --json-input | ||
| Read JSON data from stdin | ||
|
|
||
| --json-output | ||
| Print JSON data instead of an ASCII chart | ||
|
|
||
| -b, --bytes-format <BYTES_FORMAT> | ||
| How to display the numbers of bytes | ||
|
|
||
| Possible values: | ||
| - plain: Display plain number of bytes without units | ||
| - metric: Use metric scale, i.e. 1K = 1000B, 1M = 1000K, and so on | ||
| - binary: Use binary scale, i.e. 1K = 1024B, 1M = 1024K, and so on | ||
|
|
||
| [default: metric] | ||
|
|
||
| -H, --deduplicate-hardlinks | ||
| Detect and subtract the sizes of hardlinks from their parent directory totals | ||
|
|
||
| [aliases: --detect-links, --dedupe-links] | ||
|
KSXGitHub marked this conversation as resolved.
|
||
|
|
||
| --top-down | ||
| Print the tree top-down instead of bottom-up | ||
|
|
||
| --align-right | ||
| Set the root of the bars to the right | ||
|
|
||
| -q, --quantity <QUANTITY> | ||
| Aspect of the files/directories to be measured | ||
|
|
||
| Possible values: | ||
| - apparent-size: Measure apparent sizes | ||
| - block-size: Measure block sizes (block-count * 512B) | ||
| - block-count: Count numbers of blocks | ||
|
|
||
| [default: block-size] | ||
|
|
||
| -d, --max-depth <MAX_DEPTH> | ||
| Maximum depth to display the data. Could be either "inf" or a positive integer | ||
|
|
||
| [default: 10] | ||
| [aliases: --depth] | ||
|
|
||
| -w, --total-width <TOTAL_WIDTH> | ||
| Width of the visualization | ||
|
|
||
| [aliases: --width] | ||
|
|
||
| --column-width <TREE_WIDTH> <BAR_WIDTH> | ||
| Maximum widths of the tree column and width of the bar column | ||
|
|
||
| -m, --min-ratio <MIN_RATIO> | ||
| Minimal size proportion required to appear | ||
|
|
||
| [default: 0.01] | ||
|
|
||
| --no-sort | ||
| Do not sort the branches in the tree | ||
|
|
||
| -s, --silent-errors | ||
| Prevent filesystem error messages from appearing in stderr | ||
|
|
||
| [aliases: --no-errors] | ||
|
|
||
| -p, --progress | ||
| Report progress being made at the expense of performance | ||
|
|
||
| --threads <THREADS> | ||
| Set the maximum number of threads to spawn. Could be either "auto", "max", or a positive integer | ||
|
|
||
| [default: auto] | ||
|
|
||
| --omit-json-shared-details | ||
| Do not output `.shared.details` in the JSON output | ||
|
|
||
| --omit-json-shared-summary | ||
| Do not output `.shared.summary` in the JSON output | ||
|
|
||
| -h, --help | ||
| Print help (see a summary with '-h') | ||
|
|
||
| -V, --version | ||
| Print version | ||
|
|
||
| Examples: | ||
| Show disk usage chart of current working directory | ||
| $ pdu | ||
|
|
||
| Show disk usage chart of a single file or directory | ||
| $ pdu path/to/file/or/directory | ||
|
|
||
| Compare disk usages of multiple files and/or directories | ||
| $ pdu file.txt dir/ | ||
|
|
||
| Show chart in apparent sizes instead of block sizes | ||
| $ pdu --quantity=apparent-size | ||
|
|
||
| Detect and subtract the sizes of hardlinks from their parent nodes | ||
| $ pdu --deduplicate-hardlinks | ||
|
|
||
| Show sizes in plain numbers instead of metric units | ||
| $ pdu --bytes-format=plain | ||
|
|
||
| Show sizes in base 2¹⁰ units (binary) instead of base 10³ units (metric) | ||
| $ pdu --bytes-format=binary | ||
|
|
||
| Show disk usage chart of all entries regardless of size | ||
| $ pdu --min-ratio=0 | ||
|
|
||
| Only show disk usage chart of entries whose size is at least 5% of total | ||
| $ pdu --min-ratio=0.05 | ||
|
|
||
| Show disk usage data as JSON instead of chart | ||
| $ pdu --min-ratio=0 --max-depth=inf --json-output | jq | ||
|
|
||
| Visualize existing JSON representation of disk usage data | ||
| $ pdu --json-input < disk-usage.json | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.