mirror of
https://github.com/bootandy/dust.git
synced 2026-06-08 11:29:05 +03:00
@@ -35,6 +35,8 @@ _dust() {
|
|||||||
'--version[Print version information]' \
|
'--version[Print version information]' \
|
||||||
'-p[Subdirectories will not have their path shortened]' \
|
'-p[Subdirectories will not have their path shortened]' \
|
||||||
'--full-paths[Subdirectories will not have their path shortened]' \
|
'--full-paths[Subdirectories will not have their path shortened]' \
|
||||||
|
'-l[Ignore links]' \
|
||||||
|
'--ignore-links[Ignore links]' \
|
||||||
'-x[Only count the files and directories on the same filesystem as the supplied directory]' \
|
'-x[Only count the files and directories on the same filesystem as the supplied directory]' \
|
||||||
'--limit-filesystem[Only count the files and directories on the same filesystem as the supplied directory]' \
|
'--limit-filesystem[Only count the files and directories on the same filesystem as the supplied directory]' \
|
||||||
'-s[Use file length instead of blocks]' \
|
'-s[Use file length instead of blocks]' \
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ Register-ArgumentCompleter -Native -CommandName 'dust' -ScriptBlock {
|
|||||||
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version information')
|
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version information')
|
||||||
[CompletionResult]::new('-p', 'p', [CompletionResultType]::ParameterName, 'Subdirectories will not have their path shortened')
|
[CompletionResult]::new('-p', 'p', [CompletionResultType]::ParameterName, 'Subdirectories will not have their path shortened')
|
||||||
[CompletionResult]::new('--full-paths', 'full-paths', [CompletionResultType]::ParameterName, 'Subdirectories will not have their path shortened')
|
[CompletionResult]::new('--full-paths', 'full-paths', [CompletionResultType]::ParameterName, 'Subdirectories will not have their path shortened')
|
||||||
|
[CompletionResult]::new('-l', 'l', [CompletionResultType]::ParameterName, 'Ignore links')
|
||||||
|
[CompletionResult]::new('--ignore-links', 'ignore-links', [CompletionResultType]::ParameterName, 'Ignore links')
|
||||||
[CompletionResult]::new('-x', 'x', [CompletionResultType]::ParameterName, 'Only count the files and directories on the same filesystem as the supplied directory')
|
[CompletionResult]::new('-x', 'x', [CompletionResultType]::ParameterName, 'Only count the files and directories on the same filesystem as the supplied directory')
|
||||||
[CompletionResult]::new('--limit-filesystem', 'limit-filesystem', [CompletionResultType]::ParameterName, 'Only count the files and directories on the same filesystem as the supplied directory')
|
[CompletionResult]::new('--limit-filesystem', 'limit-filesystem', [CompletionResultType]::ParameterName, 'Only count the files and directories on the same filesystem as the supplied directory')
|
||||||
[CompletionResult]::new('-s', 's', [CompletionResultType]::ParameterName, 'Use file length instead of blocks')
|
[CompletionResult]::new('-s', 's', [CompletionResultType]::ParameterName, 'Use file length instead of blocks')
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ _dust() {
|
|||||||
|
|
||||||
case "${cmd}" in
|
case "${cmd}" in
|
||||||
dust)
|
dust)
|
||||||
opts="-h -V -d -n -p -X -x -s -r -c -b -z -f -i -v -e -t -w -H -D --help --version --depth --number-of-lines --full-paths --ignore-directory --limit-filesystem --apparent-size --reverse --no-colors --no-percent-bars --min-size --skip-total --filecount --ignore_hidden --invert-filter --filter --file_types --terminal_width --si --only-dir <inputs>..."
|
opts="-h -V -d -n -p -X -l -x -s -r -c -b -z -f -i -v -e -t -w -H -D --help --version --depth --number-of-lines --full-paths --ignore-directory --ignore-links --limit-filesystem --apparent-size --reverse --no-colors --no-percent-bars --min-size --skip-total --filecount --ignore_hidden --invert-filter --filter --file_types --terminal_width --si --only-dir <inputs>..."
|
||||||
if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
|
if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
|
||||||
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ set edit:completion:arg-completer[dust] = {|@words|
|
|||||||
cand --version 'Print version information'
|
cand --version 'Print version information'
|
||||||
cand -p 'Subdirectories will not have their path shortened'
|
cand -p 'Subdirectories will not have their path shortened'
|
||||||
cand --full-paths 'Subdirectories will not have their path shortened'
|
cand --full-paths 'Subdirectories will not have their path shortened'
|
||||||
|
cand -l 'Ignore links'
|
||||||
|
cand --ignore-links 'Ignore links'
|
||||||
cand -x 'Only count the files and directories on the same filesystem as the supplied directory'
|
cand -x 'Only count the files and directories on the same filesystem as the supplied directory'
|
||||||
cand --limit-filesystem 'Only count the files and directories on the same filesystem as the supplied directory'
|
cand --limit-filesystem 'Only count the files and directories on the same filesystem as the supplied directory'
|
||||||
cand -s 'Use file length instead of blocks'
|
cand -s 'Use file length instead of blocks'
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ complete -c dust -s w -l terminal_width -d 'Specify width of output overriding t
|
|||||||
complete -c dust -s h -l help -d 'Print help information'
|
complete -c dust -s h -l help -d 'Print help information'
|
||||||
complete -c dust -s V -l version -d 'Print version information'
|
complete -c dust -s V -l version -d 'Print version information'
|
||||||
complete -c dust -s p -l full-paths -d 'Subdirectories will not have their path shortened'
|
complete -c dust -s p -l full-paths -d 'Subdirectories will not have their path shortened'
|
||||||
|
complete -c dust -s l -l ignore-links -d 'Ignore links'
|
||||||
complete -c dust -s x -l limit-filesystem -d 'Only count the files and directories on the same filesystem as the supplied directory'
|
complete -c dust -s x -l limit-filesystem -d 'Only count the files and directories on the same filesystem as the supplied directory'
|
||||||
complete -c dust -s s -l apparent-size -d 'Use file length instead of blocks'
|
complete -c dust -s s -l apparent-size -d 'Use file length instead of blocks'
|
||||||
complete -c dust -s r -l reverse -d 'Print tree upside down (biggest highest)'
|
complete -c dust -s r -l reverse -d 'Print tree upside down (biggest highest)'
|
||||||
|
|||||||
@@ -34,6 +34,12 @@ pub fn build_cli() -> Command<'static> {
|
|||||||
.multiple_occurrences(true)
|
.multiple_occurrences(true)
|
||||||
.help("Exclude any file or directory with this name"),
|
.help("Exclude any file or directory with this name"),
|
||||||
)
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::new("ignore_links")
|
||||||
|
.short('l')
|
||||||
|
.long("ignore-links")
|
||||||
|
.help("Ignore links"),
|
||||||
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new("limit_filesystem")
|
Arg::new("limit_filesystem")
|
||||||
.short('x')
|
.short('x')
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ pub struct WalkData<'a> {
|
|||||||
pub use_apparent_size: bool,
|
pub use_apparent_size: bool,
|
||||||
pub by_filecount: bool,
|
pub by_filecount: bool,
|
||||||
pub ignore_hidden: bool,
|
pub ignore_hidden: bool,
|
||||||
|
pub ignore_links: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn walk_it(dirs: HashSet<PathBuf>, walk_data: WalkData) -> (Vec<Node>, bool) {
|
pub fn walk_it(dirs: HashSet<PathBuf>, walk_data: WalkData) -> (Vec<Node>, bool) {
|
||||||
@@ -143,6 +144,9 @@ fn walk(
|
|||||||
|
|
||||||
if !ignore_file(entry, walk_data) {
|
if !ignore_file(entry, walk_data) {
|
||||||
if let Ok(data) = entry.file_type() {
|
if let Ok(data) = entry.file_type() {
|
||||||
|
if data.is_symlink() && walk_data.ignore_links {
|
||||||
|
return None
|
||||||
|
}
|
||||||
return if data.is_dir() && !data.is_symlink() {
|
return if data.is_dir() && !data.is_symlink() {
|
||||||
walk(entry.path(), permissions_flag, walk_data, depth + 1)
|
walk(entry.path(), permissions_flag, walk_data, depth + 1)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -152,6 +152,7 @@ fn main() {
|
|||||||
|
|
||||||
let by_filecount = options.is_present("by_filecount");
|
let by_filecount = options.is_present("by_filecount");
|
||||||
let limit_filesystem = options.is_present("limit_filesystem");
|
let limit_filesystem = options.is_present("limit_filesystem");
|
||||||
|
let ignore_links = options.is_present("ignore_links");
|
||||||
|
|
||||||
let simplified_dirs = simplify_dir_names(target_dirs);
|
let simplified_dirs = simplify_dir_names(target_dirs);
|
||||||
let allowed_filesystems = limit_filesystem
|
let allowed_filesystems = limit_filesystem
|
||||||
@@ -167,6 +168,7 @@ fn main() {
|
|||||||
filter_regex: &filter_regexs,
|
filter_regex: &filter_regexs,
|
||||||
invert_filter_regex: &invert_filter_regexs,
|
invert_filter_regex: &invert_filter_regexs,
|
||||||
allowed_filesystems,
|
allowed_filesystems,
|
||||||
|
ignore_links,
|
||||||
use_apparent_size: config.get_apparent_size(&options),
|
use_apparent_size: config.get_apparent_size(&options),
|
||||||
by_filecount,
|
by_filecount,
|
||||||
ignore_hidden: config.get_ignore_hidden(&options),
|
ignore_hidden: config.get_ignore_hidden(&options),
|
||||||
|
|||||||
+3
-1
@@ -21,7 +21,9 @@ pub fn get_metadata(d: &Path, use_apparent_size: bool) -> Option<(u64, Option<(u
|
|||||||
Some((md.blocks() * get_block_size(), Some((md.ino(), md.dev()))))
|
Some((md.blocks() * get_block_size(), Some((md.ino(), md.dev()))))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(_e) => None,
|
Err(_e) => {
|
||||||
|
None
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user