summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTaro Tanaka <mkrmdk@gmail.com>2024-04-28 17:06:10 +0900
committerandy.boot <bootandy@gmail.com>2024-05-01 20:19:58 +0100
commite2fe6562960cbed38801393a3295a1876a01193b (patch)
treebe41ca1f319d3dc1a40521e0eb3fa1c5e34a4fa8
parent87581f328e3e9ac9e49cdaee92446b9e2e7fb424 (diff)
Redo 'Fix zsh completion' with clap
Because I'm not familiar with Rust, when I was working on https://github.com/bootandy/dust/pull/390 I didn't realize that the completions were auto-generated via clap. I'm sorry. This redoes it with clap. This improves not only the completions but also the --help and the man page. Also the --output-format flag will raise an error if the given value is invalid.
-rw-r--r--completions/_dust57
-rw-r--r--completions/_dust.ps14
-rw-r--r--completions/dust.bash28
-rw-r--r--completions/dust.elv4
-rw-r--r--completions/dust.fish6
-rw-r--r--man-page/dust.130
-rw-r--r--src/cli.rs43
7 files changed, 106 insertions, 66 deletions
diff --git a/completions/_dust b/completions/_dust
index 6f5fc10..ea66727 100644
--- a/completions/_dust
+++ b/completions/_dust
@@ -15,26 +15,26 @@ _dust() {
local context curcontext="$curcontext" state line
_arguments "${_arguments_options[@]}" \
-'-d+[Depth to show]:depth' \
-'--depth=[Depth to show]:depth' \
-'-n+[Number of lines of output to show. (Default is terminal_height - 10)]:number of lines' \
-'--number-of-lines=[Number of lines of output to show. (Default is terminal_height - 10)]:number of lines' \
-'*-X+[Exclude any file or directory with this name]:ignore directory:_files' \
-'*--ignore-directory=[Exclude any file or directory with this name]:ignore directory:_files' \
-'-I+[Exclude any file or directory with a regex matching that listed in this file, the file entries will be added to the ignore regexs provided by --invert_filter]:ignore all in file:_files' \
-'--ignore-all-in-file=[Exclude any file or directory with a regex matching that listed in this file, the file entries will be added to the ignore regexs provided by --invert_filter]:ignore all in file:_files' \
-'-z+[Minimum size file to include in output]:min size' \
-'--min-size=[Minimum size file to include in output]:min size' \
-'(-e --filter -t --file_types)*-v+[Exclude filepaths matching this regex. To ignore png files type\: -v "\\.png\$" ]:invert filter' \
-'(-e --filter -t --file_types)*--invert-filter=[Exclude filepaths matching this regex. To ignore png files type\: -v "\\.png\$" ]:invert filter' \
-'(-t --file_types)*-e+[Only include filepaths matching this regex. For png files type\: -e "\\.png\$" ]:filter' \
-'(-t --file_types)*--filter=[Only include filepaths matching this regex. For png files type\: -e "\\.png\$" ]:filter' \
-'-w+[Specify width of output overriding the auto detection of terminal width]:width' \
-'--terminal_width=[Specify width of output overriding the auto detection of terminal width]:width' \
-'-o+[Changes output display size. si will print sizes in powers of 1000. b/bytes kb kib mb mib gb gib will print the whole tree in that size]:output format:_dust_output_formats' \
-'--output-format=[Changes output display size. si will print sizes in powers of 1000. b/bytes kb kib mb mib gb gib will print the whole tree in that size]:output format:_dust_output_formats' \
-'-S+[Specify memory to use as stack size - use if you see\: '\''fatal runtime error\: stack overflow'\'' (default low memory=1048576, high memory=1073741824)]:stack size' \
-'--stack-size=[Specify memory to use as stack size - use if you see\: '\''fatal runtime error\: stack overflow'\'' (default low memory=1048576, high memory=1073741824)]:stack size' \
+'-d+[Depth to show]:DEPTH: ' \
+'--depth=[Depth to show]:DEPTH: ' \
+'-n+[Number of lines of output to show. (Default is terminal_height - 10)]:NUMBER: ' \
+'--number-of-lines=[Number of lines of output to show. (Default is terminal_height - 10)]:NUMBER: ' \
+'*-X+[Exclude any file or directory with this name]:PATH:_files' \
+'*--ignore-directory=[Exclude any file or directory with this name]:PATH:_files' \
+'-I+[Exclude any file or directory with a regex matching that listed in this file, the file entries will be added to the ignore regexs provided by --invert_filter]:FILE:_files' \
+'--ignore-all-in-file=[Exclude any file or directory with a regex matching that listed in this file, the file entries will be added to the ignore regexs provided by --invert_filter]:FILE:_files' \
+'-z+[Minimum size file to include in output]:MIN_SIZE: ' \
+'--min-size=[Minimum size file to include in output]:MIN_SIZE: ' \
+'(-e --filter -t --file_types)*-v+[Exclude filepaths matching this regex. To ignore png files type\: -v "\\.png\$" ]:REGEX: ' \
+'(-e --filter -t --file_types)*--invert-filter=[Exclude filepaths matching this regex. To ignore png files type\: -v "\\.png\$" ]:REGEX: ' \
+'(-t --file_types)*-e+[Only include filepaths matching this regex. For png files type\: -e "\\.png\$" ]:REGEX: ' \
+'(-t --file_types)*--filter=[Only include filepaths matching this regex. For png files type\: -e "\\.png\$" ]:REGEX: ' \
+'-w+[Specify width of output overriding the auto detection of terminal width]:WIDTH: ' \
+'--terminal_width=[Specify width of output overriding the auto detection of terminal width]:WIDTH: ' \
+'-o+[Changes output display size. si will print sizes in powers of 1000. b k m g t kb mb gb tb will print the whole tree in that size.]:FORMAT:(si b k m g t kb mb gb tb)' \
+'--output-format=[Changes output display size. si will print sizes in powers of 1000. b k m g t kb mb gb tb will print the whole tree in that size.]:FORMAT:(si b k m g t kb mb gb tb)' \
+'-S+[Specify memory to use as stack size - use if you see\: '\''fatal runtime error\: stack overflow'\'' (default low memory=1048576, high memory=1073741824)]:STACK_SIZE: ' \
+'--stack-size=[Specify memory to use as stack size - use if you see\: '\''fatal runtime error\: stack overflow'\'' (default low memory=1048576, high memory=1073741824)]:STACK_SIZE: ' \
'-p[Subdirectories will not have their path shortened]' \
'--full-paths[Subdirectories will not have their path shortened]' \
'-L[dereference sym links - Treat sym links as directories and go into them]' \
@@ -72,7 +72,7 @@ _dust() {
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
-'*: :_files' \
+'*::params:_files' \
&& ret=0
}
@@ -82,21 +82,6 @@ _dust_commands() {
_describe -t commands 'dust commands' commands "$@"
}
-(( $+functions[_dust_output_formats] )) ||
-_dust_output_formats() {
- local -a output_formats=(
- 'si[sizes in powers of 1000]'
- 'b[bytes]'
- 'kb[kilobytes]'
- 'kib[kibibytes]'
- 'mb[megabytes]'
- 'mib[mebibytes]'
- 'gb[gigabytes]'
- 'gib[gibibytes]'
- )
- _values 'output format' "${output_formats[@]}"
-}
-
if [ "$funcstack[1]" = "_dust" ]; then
_dust "$@"
else
diff --git a/completions/_dust.ps1 b/completions/_dust.ps1
index 484d20e..59fef61 100644
--- a/completions/_dust.ps1
+++ b/completions/_dust.ps1
@@ -37,8 +37,8 @@ Register-ArgumentCompleter -Native -CommandName 'dust' -ScriptBlock {
[CompletionResult]::new('--filter', 'filter', [CompletionResultType]::ParameterName, 'Only include filepaths matching this regex. For png files type: -e "\.png$" ')
[CompletionResult]::new('-w', 'w', [CompletionResultType]::ParameterName, 'Specify width of output overriding the auto detection of terminal width')
[CompletionResult]::new('--terminal_width', 'terminal_width', [CompletionResultType]::ParameterName, 'Specify width of output overriding the auto detection of terminal width')
- [CompletionResult]::new('-o', 'o', [CompletionResultType]::ParameterName, 'Changes output display size. si will print sizes in powers of 1000. b/bytes kb kib mb mib gb gib will print the whole tree in that size')
- [CompletionResult]::new('--output-format', 'output-format', [CompletionResultType]::ParameterName, 'Changes output display size. si will print sizes in powers of 1000. b/bytes kb kib mb mib gb gib will print the whole tree in that size')
+ [CompletionResult]::new('-o', 'o', [CompletionResultType]::ParameterName, 'Changes output display size. si will print sizes in powers of 1000. b k m g t kb mb gb tb will print the whole tree in that size.')
+ [CompletionResult]::new('--output-format', 'output-format', [CompletionResultType]::ParameterName, 'Changes output display size. si will print sizes in powers of 1000. b k m g t kb mb gb tb will print the whole tree in that size.')
[CompletionResult]::new('-S', 'S ', [CompletionResultType]::ParameterName, 'Specify memory to use as stack size - use if you see: ''fatal runtime error: stack overflow'' (default low memory=1048576, high memory=1073741824)')
[CompletionResult]::new('--stack-size', 'stack-size', [CompletionResultType]::ParameterName, 'Specify memory to use as stack size - use if you see: ''fatal runtime error: stack overflow'' (default low memory=1048576, high memory=1073741824)')
[CompletionResult]::new('-p', 'p', [CompletionResultType]::ParameterName, 'Subdirectories will not have their path shortened')
diff --git a/completions/dust.bash b/completions/dust.bash
index b332455..24d397b 100644
--- a/completions/dust.bash
+++ b/completions/dust.bash
@@ -19,7 +19,7 @@ _dust() {
case "${cmd}" in
dust)
- opts="-d -n -p -X -I -L -x -s -r -c -C -b -B -z -R -f -i -v -e -t -w -P -D -F -o -S -h -V --depth --number-of-lines --full-paths --ignore-directory --ignore-all-in-file --dereference-links --limit-filesystem --apparent-size --reverse --no-colors --force-colors --no-percent-bars --bars-on-right --min-size --screen-reader --skip-total --filecount --ignore_hidden --invert-filter --filter --file_types --terminal_width --no-progress --only-dir --only-file --output-format --stack-size --help --version [params]..."
+ opts="-d -n -p -X -I -L -x -s -r -c -C -b -B -z -R -f -i -v -e -t -w -P -D -F -o -S -h -V --depth --number-of-lines --full-paths --ignore-directory --ignore-all-in-file --dereference-links --limit-filesystem --apparent-size --reverse --no-colors --force-colors --no-percent-bars --bars-on-right --min-size --screen-reader --skip-total --filecount --ignore_hidden --invert-filter --filter --file_types --terminal_width --no-progress --only-dir --only-file --output-format --stack-size --help --version [PATH]..."
if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
@@ -50,11 +50,33 @@ _dust() {
return 0
;;
--ignore-all-in-file)
+ local oldifs
+ if [[ -v IFS ]]; then
+ oldifs="$IFS"
+ fi
+ IFS=$'\n'
COMPREPLY=($(compgen -f "${cur}"))
+ if [[ -v oldifs ]]; then
+ IFS="$oldifs"
+ fi
+ if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then
+ compopt -o filenames
+ fi
return 0
;;
-I)
+ local oldifs
+ if [[ -v IFS ]]; then
+ oldifs="$IFS"
+ fi
+ IFS=$'\n'
COMPREPLY=($(compgen -f "${cur}"))
+ if [[ -v oldifs ]]; then
+ IFS="$oldifs"
+ fi
+ if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then
+ compopt -o filenames
+ fi
return 0
;;
--min-size)
@@ -90,11 +112,11 @@ _dust() {
return 0
;;
--output-format)
- COMPREPLY=($(compgen -f "${cur}"))
+ COMPREPLY=($(compgen -W "si b k m g t kb mb gb tb" -- "${cur}"))
return 0
;;
-o)
- COMPREPLY=($(compgen -f "${cur}"))
+ COMPREPLY=($(compgen -W "si b k m g t kb mb gb tb" -- "${cur}"))
return 0
;;
--stack-size)
diff --git a/completions/dust.elv b/completions/dust.elv
index 921c4e9..a8c072e 100644
--- a/completions/dust.elv
+++ b/completions/dust.elv
@@ -34,8 +34,8 @@ set edit:completion:arg-completer[dust] = {|@words|
cand --filter 'Only include filepaths matching this regex. For png files type: -e "\.png$" '
cand -w 'Specify width of output overriding the auto detection of terminal width'
cand --terminal_width 'Specify width of output overriding the auto detection of terminal width'
- cand -o 'Changes output display size. si will print sizes in powers of 1000. b/bytes kb kib mb mib gb gib will print the whole tree in that size'
- cand --output-format 'Changes output display size. si will print sizes in powers of 1000. b/bytes kb kib mb mib gb gib will print the whole tree in that size'
+ cand -o 'Changes output display size. si will print sizes in powers of 1000. b k m g t kb mb gb tb will print the whole tree in that size.'
+ cand --output-format 'Changes output display size. si will print sizes in powers of 1000. b k m g t kb mb gb tb will print the whole tree in that size.'
cand -S 'Specify memory to use as stack size - use if you see: ''fatal runtime error: stack overflow'' (default low memory=1048576, high memory=1073741824)'
cand --stack-size 'Specify memory to use as stack size - use if you see: ''fatal runtime error: stack overflow'' (default low memory=1048576, high memory=1073741824)'
cand -p 'Subdirectories will not have their path shortened'
diff --git a/completions/dust.fish b/completions/dust.fish
index 4b09292..546cfdb 100644
--- a/completions/dust.fish
+++ b/completions/dust.fish
@@ -1,12 +1,12 @@
complete -c dust -s d -l depth -d 'Depth to show' -r
complete -c dust -s n -l number-of-lines -d 'Number of lines of output to show. (Default is terminal_height - 10)' -r
-complete -c dust -s X -l ignore-directory -d 'Exclude any file or directory with this name' -r
-complete -c dust -s I -l ignore-all-in-file -d 'Exclude any file or directory with a regex matching that listed in this file, the file entries will be added to the ignore regexs provided by --invert_filter' -r
+complete -c dust -s X -l ignore-directory -d 'Exclude any file or directory with this name' -r -F
+complete -c dust -s I -l ignore-all-in-file -d 'Exclude any file or directory with a regex matching that listed in this file, the file entries will be added to the ignore regexs provided by --invert_filter' -r -F
complete -c dust -s z -l min-size -d 'Minimum size file to include in output' -r
complete -c dust -s v -l invert-filter -d 'Exclude filepaths matching this regex. To ignore png files type: -v "\\.png$" ' -r
complete -c dust -s e -l filter -d 'Only include filepaths matching this regex. For png files type: -e "\\.png$" ' -r
complete -c dust -s w -l terminal_width -d 'Specify width of output overriding the auto detection of terminal width' -r
-complete -c dust -s o -l output-format -d 'Changes output display size. si will print sizes in powers of 1000. b/bytes kb kib mb mib gb gib will print the whole tree in that size' -r
+complete -c dust -s o -l output-format -d 'Changes output display size. si will print sizes in powers of 1000. b k m g t kb mb gb tb will print the whole tree in that size.' -r -f -a "{si '',b '',k '',m '',g '',t '',kb '',mb '',gb '',tb ''}"
complete -c dust -s S -l stack-size -d 'Specify memory to use as stack size - use if you see: \'fatal runtime error: stack overflow\' (default low memory=1048576, high memory=1073741824)' -r
complete -c dust -s p -l full-paths -d 'Subdirectories will not have their path shortened'
complete -c dust -s L -l dereference-links -d 'dereference sym links - Treat sym links as directories and go into them'
diff --git a/man-page/dust.1 b/man-page/dust.1
index 74232d8..9253b8b 100644
--- a/man-page/dust.1
+++ b/man-page/dust.1
@@ -4,24 +4,24 @@
.SH NAME
Dust \- Like du but more intuitive
.SH SYNOPSIS
-\fBdust\fR [\fB\-d\fR|\fB\-\-depth\fR] [\fB\-n\fR|\fB\-\-number\-of\-lines\fR] [\fB\-p\fR|\fB\-\-full\-paths\fR] [\fB\-X\fR|\fB\-\-ignore\-directory\fR] [\fB\-I\fR|\fB\-\-ignore\-all\-in\-file\fR] [\fB\-L\fR|\fB\-\-dereference\-links\fR] [\fB\-x\fR|\fB\-\-limit\-filesystem\fR] [\fB\-s\fR|\fB\-\-apparent\-size\fR] [\fB\-r\fR|\fB\-\-reverse\fR] [\fB\-c\fR|\fB\-\-no\-colors\fR] [\fB\-C\fR|\fB\-\-force\-colors\fR] [\fB\-b\fR|\fB\-\-no\-percent\-bars\fR] [\fB\-B\fR|\fB\-\-bars\-on\-right\fR] [\fB\-z\fR|\fB\-\-min\-size\fR] [\fB\-R\fR|\fB\-\-screen\-reader\fR] [\fB\-\-skip\-total\fR] [\fB\-f\fR|\fB\-\-filecount\fR] [\fB\-i\fR|\fB\-\-ignore_hidden\fR] [\fB\-v\fR|\fB\-\-invert\-filter\fR] [\fB\-e\fR|\fB\-\-filter\fR] [\fB\-t\fR|\fB\-\-file_types\fR] [\fB\-w\fR|\fB\-\-terminal_width\fR] [\fB\-P\fR|\fB\-\-no\-progress\fR] [\fB\-D\fR|\fB\-\-only\-dir\fR] [\fB\-F\fR|\fB\-\-only\-file\fR] [\fB\-o\fR|\fB\-\-output\-format\fR] [\fB\-S\fR|\fB\-\-stack\-size\fR] [\fB\-h\fR|\fB\-\-help\fR] [\fB\-V\fR|\fB\-\-version\fR] [\fIparams\fR]
+\fBdust\fR [\fB\-d\fR|\fB\-\-depth\fR] [\fB\-n\fR|\fB\-\-number\-of\-lines\fR] [\fB\-p\fR|\fB\-\-full\-paths\fR] [\fB\-X\fR|\fB\-\-ignore\-directory\fR] [\fB\-I\fR|\fB\-\-ignore\-all\-in\-file\fR] [\fB\-L\fR|\fB\-\-dereference\-links\fR] [\fB\-x\fR|\fB\-\-limit\-filesystem\fR] [\fB\-s\fR|\fB\-\-apparent\-size\fR] [\fB\-r\fR|\fB\-\-reverse\fR] [\fB\-c\fR|\fB\-\-no\-colors\fR] [\fB\-C\fR|\fB\-\-force\-colors\fR] [\fB\-b\fR|\fB\-\-no\-percent\-bars\fR] [\fB\-B\fR|\fB\-\-bars\-on\-right\fR] [\fB\-z\fR|\fB\-\-min\-size\fR] [\fB\-R\fR|\fB\-\-screen\-reader\fR] [\fB\-\-skip\-total\fR] [\fB\-f\fR|\fB\-\-filecount\fR] [\fB\-i\fR|\fB\-\-ignore_hidden\fR] [\fB\-v\fR|\fB\-\-invert\-filter\fR] [\fB\-e\fR|\fB\-\-filter\fR] [\fB\-t\fR|\fB\-\-file_types\fR] [\fB\-w\fR|\fB\-\-terminal_width\fR] [\fB\-P\fR|\fB\-\-no\-progress\fR] [\fB\-D\fR|\fB\-\-only\-dir\fR] [\fB\-F\fR|\fB\-\-only\-file\fR] [\fB\-o\fR|\fB\-\-output\-format\fR] [\fB\-S\fR|\fB\-\-stack\-size\fR] [\fB\-h\fR|\fB\-\-help\fR] [\fB\-V\fR|\fB\-\-version\fR] [\fIPATH\fR]
.SH DESCRIPTION
Like du but more intuitive
.SH OPTIONS
.TP
-\fB\-d\fR, \fB\-\-depth\fR
+\fB\-d\fR, \fB\-\-depth\fR=\fIDEPTH\fR
Depth to show
.TP
-\fB\-n\fR, \fB\-\-number\-of\-lines\fR
+\fB\-n\fR, \fB\-\-number\-of\-lines\fR=\fINUMBER\fR
Number of lines of output to show. (Default is terminal_height \- 10)
.TP
\fB\-p\fR, \fB\-\-full\-paths\fR
Subdirectories will not have their path shortened
.TP
-\fB\-X\fR, \fB\-\-ignore\-directory\fR
+\fB\-X\fR, \fB\-\-ignore\-directory\fR=\fIPATH\fR
Exclude any file or directory with this name
.TP
-\fB\-I\fR, \fB\-\-ignore\-all\-in\-file\fR
+\fB\-I\fR, \fB\-\-ignore\-all\-in\-file\fR=\fIFILE\fR
Exclude any file or directory with a regex matching that listed in this file, the file entries will be added to the ignore regexs provided by \-\-invert_filter
.TP
\fB\-L\fR, \fB\-\-dereference\-links\fR
@@ -48,7 +48,7 @@ No percent bars or percentages will be displayed
\fB\-B\fR, \fB\-\-bars\-on\-right\fR
percent bars moved to right side of screen
.TP
-\fB\-z\fR, \fB\-\-min\-size\fR
+\fB\-z\fR, \fB\-\-min\-size\fR=\fIMIN_SIZE\fR
Minimum size file to include in output
.TP
\fB\-R\fR, \fB\-\-screen\-reader\fR
@@ -63,16 +63,16 @@ Directory \*(Aqsize\*(Aq is number of child files instead of disk size
\fB\-i\fR, \fB\-\-ignore_hidden\fR
Do not display hidden files
.TP
-\fB\-v\fR, \fB\-\-invert\-filter\fR
+\fB\-v\fR, \fB\-\-invert\-filter\fR=\fIREGEX\fR
Exclude filepaths matching this regex. To ignore png files type: \-v "\\.png$"
.TP
-\fB\-e\fR, \fB\-\-filter\fR
+\fB\-e\fR, \fB\-\-filter\fR=\fIREGEX\fR
Only include filepaths matching this regex. For png files type: \-e "\\.png$"
.TP
\fB\-t\fR, \fB\-\-file_types\fR
show only these file types
.TP
-\fB\-w\fR, \fB\-\-terminal_width\fR
+\fB\-w\fR, \fB\-\-terminal_width\fR=\fIWIDTH\fR
Specify width of output overriding the auto detection of terminal width
.TP
\fB\-P\fR, \fB\-\-no\-progress\fR
@@ -84,10 +84,14 @@ Only directories will be displayed.
\fB\-F\fR, \fB\-\-only\-file\fR
Only files will be displayed. (Finds your largest files)
.TP
-\fB\-o\fR, \fB\-\-output\-format\fR
-Changes output display size. si will print sizes in powers of 1000. b/bytes kb kib mb mib gb gib will print the whole tree in that size
+\fB\-o\fR, \fB\-\-output\-format\fR=\fIFORMAT\fR
+Changes output display size. si will print sizes in powers of 1000. b k m g t kb mb gb tb will print the whole tree in that size.
+.br
+
+.br
+[\fIpossible values: \fRsi, b, k, m, g, t, kb, mb, gb, tb]
.TP
-\fB\-S\fR, \fB\-\-stack\-size\fR
+\fB\-S\fR, \fB\-\-stack\-size\fR=\fISTACK_SIZE\fR
Specify memory to use as stack size \- use if you see: \*(Aqfatal runtime error: stack overflow\*(Aq (default low memory=1048576, high memory=1073741824)
.TP
\fB\-h\fR, \fB\-\-help\fR
@@ -96,7 +100,7 @@ Print help
\fB\-V\fR, \fB\-\-version\fR
Print version
.TP
-[\fIparams\fR]
+[\fIPATH\fR]
.SH VERSION
v1.0.0
diff --git a/src/cli.rs b/src/cli.rs
index 797b790..dcb82d9 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -1,4 +1,4 @@
-use clap::{value_parser, Arg, Command};
+use clap::{builder::PossibleValue, value_parser, Arg, Command};
// For single thread mode set this variable on your command line:
// export RAYON_NUM_THREADS=1
@@ -11,6 +11,7 @@ pub fn build_cli() -> Command {
Arg::new("depth")
.short('d')
.long("depth")
+ .value_name("DEPTH")
.value_parser(value_parser!(usize))
.help("Depth to show")
.num_args(1)
@@ -19,6 +20,7 @@ pub fn build_cli() -> Command {
Arg::new("number_of_lines")
.short('n')
.long("number-of-lines")
+ .value_name("NUMBER")
.value_parser(value_parser!(usize))
.help("Number of lines of output to show. (Default is terminal_height - 10)")
.num_args(1)
@@ -34,6 +36,8 @@ pub fn build_cli() -> Command {
Arg::new("ignore_directory")
.short('X')
.long("ignore-directory")
+ .value_name("PATH")
+ .value_hint(clap::ValueHint::AnyPath)
.action(clap::ArgAction::Append)
.help("Exclude any file or directory with this name"),
)
@@ -41,6 +45,8 @@ pub fn build_cli() -> Command {
Arg::new("ignore_all_in_file")
.short('I')
.long("ignore-all-in-file")
+ .value_name("FILE")
+ .value_hint(clap::ValueHint::FilePath)
.value_parser(value_parser!(String))
.help("Exclude any file or directory with a regex matching that listed in this file, the file entries will be added to the ignore regexs provided by --invert_filter"),
)
@@ -104,6 +110,7 @@ pub fn build_cli() -> Command {
Arg::new("min_size")
.short('z')
.long("min-size")
+ .value_name("MIN_SIZE")
.num_args(1)
.help("Minimum size file to include in output"),
)
@@ -138,6 +145,7 @@ pub fn build_cli() -> Command {
Arg::new("invert_filter")
.short('v')
.long("invert-filter")
+ .value_name("REGEX")
.action(clap::ArgAction::Append)
.conflicts_with("filter")
.conflicts_with("types")
@@ -147,6 +155,7 @@ pub fn build_cli() -> Command {
Arg::new("filter")
.short('e')
.long("filter")
+ .value_name("REGEX")
.action(clap::ArgAction::Append)
.conflicts_with("types")
.help("Only include filepaths matching this regex. For png files type: -e \"\\.png$\" "),
@@ -164,8 +173,9 @@ pub fn build_cli() -> Command {
Arg::new("width")
.short('w')
.long("terminal_width")
- .num_args(1)
+ .value_name("WIDTH")
.value_parser(value_parser!(usize))
+ .num_args(1)
.help("Specify width of output overriding the auto detection of terminal width"),
)
.arg(
@@ -196,17 +206,36 @@ pub fn build_cli() -> Command {
Arg::new("output_format")
.short('o')
.long("output-format")
- .value_parser(value_parser!(String))
- .help("Changes output display size. si will print sizes in powers of 1000. b/bytes kb kib mb mib gb gib will print the whole tree in that size")
+ .value_name("FORMAT")
+ .value_parser([
+ PossibleValue::new("si"),
+ PossibleValue::new("b"),
+ PossibleValue::new("k").alias("kib"),
+ PossibleValue::new("m").alias("mib"),
+ PossibleValue::new("g").alias("gib"),
+ PossibleValue::new("t").alias("tib"),
+ PossibleValue::new("kb"),
+ PossibleValue::new("mb"),
+ PossibleValue::new("gb"),
+ PossibleValue::new("tb"),
+ ])
+ .ignore_case(true)
+ .help("Changes output display size. si will print sizes in powers of 1000. b k m g t kb mb gb tb will print the whole tree in that size.")
)
.arg(
Arg::new("stack_size")
.short('S')
.long("stack-size")
- .num_args(1)
+ .value_name("STACK_SIZE")
.value_parser(value_parser!(usize))
+ .num_args(1)
.help("Specify memory to use as stack size - use if you see: 'fatal runtime error: stack overflow' (default low memory=1048576, high memory=1073741824)"),
)
- .arg(Arg::new("params").num_args(1..)
- .value_parser(value_parser!(String)))
+ .arg(
+ Arg::new("params")
+ .value_name("PATH")
+ .value_hint(clap::ValueHint::AnyPath)
+ .value_parser(value_parser!(String))
+ .num_args(1..)
+ )
}