Skip to content

Commit

Permalink
feat: display the size of a file or directory in "kilobytes"
Browse files Browse the repository at this point in the history
  • Loading branch information
TYzzt authored and bootandy committed Feb 21, 2024
1 parent 923a023 commit ff865c0
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 16 deletions.
4 changes: 2 additions & 2 deletions completions/_dust
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ _dust() {
'(-t --file_types)*--filter=[Only include filepaths matching this regex. For png files type\: -e "\\.png\$" ]: : ' \
'-w+[Specify width of output overriding the auto detection of terminal width]: : ' \
'--terminal_width=[Specify width of output overriding the auto detection of terminal width]: : ' \
'-k+[display the size of a file or directory in kilobytes]: : ' \
'--display-kb=[display the size of a file or directory in kilobytes]: : ' \
'-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=[Specify memory to use as stack size - use if you see\: '\''fatal runtime error\: stack overflow'\'' (default low memory=1048576, high memory=1073741824)]: : ' \
'-p[Subdirectories will not have their path shortened]' \
Expand Down Expand Up @@ -68,6 +66,8 @@ _dust() {
'(-F --only-file -t --file_types)--only-dir[Only directories will be displayed.]' \
'(-D --only-dir)-F[Only files will be displayed. (Finds your largest files)]' \
'(-D --only-dir)--only-file[Only files will be displayed. (Finds your largest files)]' \
'-k[display the size of a file or directory in kilobytes]' \
'--display-kb[display the size of a file or directory in kilobytes]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
Expand Down
4 changes: 2 additions & 2 deletions completions/_dust.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ 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('-k', 'k', [CompletionResultType]::ParameterName, 'display the size of a file or directory in kilobytes')
[CompletionResult]::new('--display-kb', 'display-kb', [CompletionResultType]::ParameterName, 'display the size of a file or directory in kilobytes')
[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')
Expand Down Expand Up @@ -74,6 +72,8 @@ Register-ArgumentCompleter -Native -CommandName 'dust' -ScriptBlock {
[CompletionResult]::new('--only-dir', 'only-dir', [CompletionResultType]::ParameterName, 'Only directories will be displayed.')
[CompletionResult]::new('-F', 'F ', [CompletionResultType]::ParameterName, 'Only files will be displayed. (Finds your largest files)')
[CompletionResult]::new('--only-file', 'only-file', [CompletionResultType]::ParameterName, 'Only files will be displayed. (Finds your largest files)')
[CompletionResult]::new('-k', 'k', [CompletionResultType]::ParameterName, 'display the size of a file or directory in kilobytes')
[CompletionResult]::new('--display-kb', 'display-kb', [CompletionResultType]::ParameterName, 'display the size of a file or directory in kilobytes')
[CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help')
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help')
[CompletionResult]::new('-V', 'V ', [CompletionResultType]::ParameterName, 'Print version')
Expand Down
8 changes: 0 additions & 8 deletions completions/dust.bash
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,6 @@ _dust() {
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
--display-kb)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
-k)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
--stack-size)
COMPREPLY=($(compgen -f "${cur}"))
return 0
Expand Down
4 changes: 2 additions & 2 deletions completions/dust.elv
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ 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 -k 'display the size of a file or directory in kilobytes'
cand --display-kb 'display the size of a file or directory in kilobytes'
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'
Expand Down Expand Up @@ -71,6 +69,8 @@ set edit:completion:arg-completer[dust] = {|@words|
cand --only-dir 'Only directories will be displayed.'
cand -F 'Only files will be displayed. (Finds your largest files)'
cand --only-file 'Only files will be displayed. (Finds your largest files)'
cand -k 'display the size of a file or directory in kilobytes'
cand --display-kb 'display the size of a file or directory in kilobytes'
cand -h 'Print help'
cand --help 'Print help'
cand -V 'Print version'
Expand Down
2 changes: 1 addition & 1 deletion completions/dust.fish
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ 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 k -l display-kb -d 'display the size of a file or directory in kilobytes' -r
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'
Expand All @@ -25,5 +24,6 @@ complete -c dust -s H -l si -d 'print sizes in powers of 1000 (e.g., 1.1G)'
complete -c dust -s P -l no-progress -d 'Disable the progress indication.'
complete -c dust -s D -l only-dir -d 'Only directories will be displayed.'
complete -c dust -s F -l only-file -d 'Only files will be displayed. (Finds your largest files)'
complete -c dust -s k -l display-kb -d 'display the size of a file or directory in kilobytes'
complete -c dust -s h -l help -d 'Print help'
complete -c dust -s V -l version -d 'Print version'
1 change: 1 addition & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ pub fn build_cli() -> Command {
Arg::new("display_kb")
.short('k')
.long("display-kb")
.action(clap::ArgAction::SetTrue)
.help("display the size of a file or directory in kilobytes"),
)
.arg(
Expand Down
3 changes: 2 additions & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pub struct Config {
pub disable_progress: Option<bool>,
pub depth: Option<usize>,
pub bars_on_right: Option<bool>,
pub display_kb: Option<bool>,
pub stack_size: Option<usize>,
}

Expand Down Expand Up @@ -105,7 +106,7 @@ impl Config {
}
}
pub fn get_display_kb(&self, options: &ArgMatches) -> bool {
Some(true) == self.only_file || options.is_present("display_kb")
Some(true) == self.display_kb || options.get_flag("display_kb")
}
}

Expand Down

0 comments on commit ff865c0

Please sign in to comment.