Skip to content

Commit 18f5d7b

Browse files
committed
feat(cli): add some aliases
1 parent 5007d31 commit 18f5d7b

6 files changed

Lines changed: 24 additions & 7 deletions

File tree

exports/completion.bash

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ _pdu() {
2323

2424
case "${cmd}" in
2525
pdu)
26-
opts="-h -V --json-input --json-output --bytes-format --top-down --align-right --quantity --max-depth --total-width --column-width --min-ratio --no-sort --silent-errors --progress --threads --help --version [FILES]..."
26+
opts="-h -V --json-input --json-output --bytes-format --top-down --align-right --quantity --depth --max-depth --width --total-width --column-width --min-ratio --no-sort --no-errors --silent-errors --progress --threads --help --version [FILES]..."
2727
if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
2828
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
2929
return 0
@@ -41,10 +41,18 @@ _pdu() {
4141
COMPREPLY=($(compgen -f "${cur}"))
4242
return 0
4343
;;
44+
--depth)
45+
COMPREPLY=($(compgen -f "${cur}"))
46+
return 0
47+
;;
4448
--total-width)
4549
COMPREPLY=($(compgen -f "${cur}"))
4650
return 0
4751
;;
52+
--width)
53+
COMPREPLY=($(compgen -f "${cur}"))
54+
return 0
55+
;;
4856
--column-width)
4957
COMPREPLY=($(compgen -f "${cur}"))
5058
return 0

exports/completion.elv

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ set edit:completion:arg-completer[pdu] = {|@words|
2121
cand --bytes-format 'How to display the numbers of bytes'
2222
cand --quantity 'Aspect of the files/directories to be measured'
2323
cand --max-depth 'Maximum depth to display the data (must be greater than 0)'
24+
cand --depth 'Maximum depth to display the data (must be greater than 0)'
2425
cand --total-width 'Width of the visualization'
26+
cand --width 'Width of the visualization'
2527
cand --column-width 'Maximum widths of the tree column and width of the bar column'
2628
cand --min-ratio 'Minimal size proportion required to appear'
2729
cand --threads 'Set the maximum number of threads to spawn. Could be either "auto", "max", or a number'
@@ -31,6 +33,7 @@ set edit:completion:arg-completer[pdu] = {|@words|
3133
cand --align-right 'Set the root of the bars to the right'
3234
cand --no-sort 'Preserve order of entries'
3335
cand --silent-errors 'Prevent filesystem error messages from appearing in stderr'
36+
cand --no-errors 'Prevent filesystem error messages from appearing in stderr'
3437
cand --progress 'Report progress being made at the expense of performance'
3538
cand -h 'Print help (see more with ''--help'')'
3639
cand --help 'Print help (see more with ''--help'')'

exports/completion.fish

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ binary\t'Use binary scale, i.e. 1K = 1024B, 1M = 1024K, and so on'"
44
complete -c pdu -l quantity -d 'Aspect of the files/directories to be measured' -r -f -a "apparent-size\t'Measure apparent sizes'
55
block-size\t'Measure block sizes (block-count * 512B)'
66
block-count\t'Count numbers of blocks'"
7-
complete -c pdu -l max-depth -d 'Maximum depth to display the data (must be greater than 0)' -r
8-
complete -c pdu -l total-width -d 'Width of the visualization' -r
7+
complete -c pdu -l max-depth -l depth -d 'Maximum depth to display the data (must be greater than 0)' -r
8+
complete -c pdu -l total-width -l width -d 'Width of the visualization' -r
99
complete -c pdu -l column-width -d 'Maximum widths of the tree column and width of the bar column' -r
1010
complete -c pdu -l min-ratio -d 'Minimal size proportion required to appear' -r
1111
complete -c pdu -l threads -d 'Set the maximum number of threads to spawn. Could be either "auto", "max", or a number' -r
@@ -14,7 +14,7 @@ complete -c pdu -l json-output -d 'Print JSON data instead of an ASCII chart'
1414
complete -c pdu -l top-down -d 'Print the tree top-down instead of bottom-up'
1515
complete -c pdu -l align-right -d 'Set the root of the bars to the right'
1616
complete -c pdu -l no-sort -d 'Preserve order of entries'
17-
complete -c pdu -l silent-errors -d 'Prevent filesystem error messages from appearing in stderr'
17+
complete -c pdu -l silent-errors -l no-errors -d 'Prevent filesystem error messages from appearing in stderr'
1818
complete -c pdu -l progress -d 'Report progress being made at the expense of performance'
1919
complete -c pdu -s h -l help -d 'Print help (see more with \'--help\')'
2020
complete -c pdu -s V -l version -d 'Print version'

exports/completion.ps1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ Register-ArgumentCompleter -Native -CommandName 'pdu' -ScriptBlock {
2424
[CompletionResult]::new('--bytes-format', '--bytes-format', [CompletionResultType]::ParameterName, 'How to display the numbers of bytes')
2525
[CompletionResult]::new('--quantity', '--quantity', [CompletionResultType]::ParameterName, 'Aspect of the files/directories to be measured')
2626
[CompletionResult]::new('--max-depth', '--max-depth', [CompletionResultType]::ParameterName, 'Maximum depth to display the data (must be greater than 0)')
27+
[CompletionResult]::new('--depth', '--depth', [CompletionResultType]::ParameterName, 'Maximum depth to display the data (must be greater than 0)')
2728
[CompletionResult]::new('--total-width', '--total-width', [CompletionResultType]::ParameterName, 'Width of the visualization')
29+
[CompletionResult]::new('--width', '--width', [CompletionResultType]::ParameterName, 'Width of the visualization')
2830
[CompletionResult]::new('--column-width', '--column-width', [CompletionResultType]::ParameterName, 'Maximum widths of the tree column and width of the bar column')
2931
[CompletionResult]::new('--min-ratio', '--min-ratio', [CompletionResultType]::ParameterName, 'Minimal size proportion required to appear')
3032
[CompletionResult]::new('--threads', '--threads', [CompletionResultType]::ParameterName, 'Set the maximum number of threads to spawn. Could be either "auto", "max", or a number')
@@ -34,6 +36,7 @@ Register-ArgumentCompleter -Native -CommandName 'pdu' -ScriptBlock {
3436
[CompletionResult]::new('--align-right', '--align-right', [CompletionResultType]::ParameterName, 'Set the root of the bars to the right')
3537
[CompletionResult]::new('--no-sort', '--no-sort', [CompletionResultType]::ParameterName, 'Preserve order of entries')
3638
[CompletionResult]::new('--silent-errors', '--silent-errors', [CompletionResultType]::ParameterName, 'Prevent filesystem error messages from appearing in stderr')
39+
[CompletionResult]::new('--no-errors', '--no-errors', [CompletionResultType]::ParameterName, 'Prevent filesystem error messages from appearing in stderr')
3740
[CompletionResult]::new('--progress', '--progress', [CompletionResultType]::ParameterName, 'Report progress being made at the expense of performance')
3841
[CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
3942
[CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')

exports/completion.zsh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ binary\:"Use binary scale, i.e. 1K = 1024B, 1M = 1024K, and so on"))' \
2222
block-size\:"Measure block sizes (block-count * 512B)"
2323
block-count\:"Count numbers of blocks"))' \
2424
'--max-depth=[Maximum depth to display the data (must be greater than 0)]:MAX_DEPTH:_default' \
25+
'--depth=[Maximum depth to display the data (must be greater than 0)]:MAX_DEPTH:_default' \
2526
'(--column-width)--total-width=[Width of the visualization]:TOTAL_WIDTH:_default' \
27+
'(--column-width)--width=[Width of the visualization]:TOTAL_WIDTH:_default' \
2628
'*--column-width=[Maximum widths of the tree column and width of the bar column]:TREE_WIDTH:_default:TREE_WIDTH:_default' \
2729
'--min-ratio=[Minimal size proportion required to appear]:MIN_RATIO:_default' \
2830
'--threads=[Set the maximum number of threads to spawn. Could be either "auto", "max", or a number]:THREADS:_default' \
@@ -32,6 +34,7 @@ block-count\:"Count numbers of blocks"))' \
3234
'--align-right[Set the root of the bars to the right]' \
3335
'--no-sort[Preserve order of entries]' \
3436
'--silent-errors[Prevent filesystem error messages from appearing in stderr]' \
37+
'--no-errors[Prevent filesystem error messages from appearing in stderr]' \
3538
'--progress[Report progress being made at the expense of performance]' \
3639
'-h[Print help (see more with '\''--help'\'')]' \
3740
'--help[Print help (see more with '\''--help'\'')]' \

src/args.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,12 @@ pub struct Args {
110110
pub quantity: Quantity,
111111

112112
/// Maximum depth to display the data (must be greater than 0).
113-
#[clap(long, default_value = "10")]
113+
#[clap(long, default_value = "10", visible_alias = "depth")]
114114
#[default(_code = "10.try_into().unwrap()")]
115115
pub max_depth: NonZeroU64,
116116

117117
/// Width of the visualization.
118-
#[clap(long, conflicts_with = "column_width")]
118+
#[clap(long, conflicts_with = "column_width", visible_alias = "width")]
119119
pub total_width: Option<usize>,
120120

121121
/// Maximum widths of the tree column and width of the bar column.
@@ -131,7 +131,7 @@ pub struct Args {
131131
pub no_sort: bool,
132132

133133
/// Prevent filesystem error messages from appearing in stderr.
134-
#[clap(long)]
134+
#[clap(long, visible_alias = "no-errors")]
135135
pub silent_errors: bool,
136136

137137
/// Report progress being made at the expense of performance.

0 commit comments

Comments
 (0)