diff --git a/exports/completion.elv b/exports/completion.elv index 4e4c3bb..d3cda52 100644 --- a/exports/completion.elv +++ b/exports/completion.elv @@ -31,7 +31,7 @@ set edit:completion:arg-completer[pdu] = {|@words| cand --column-width 'Maximum widths of the tree column and width of the bar column' cand -m 'Minimal size proportion required to appear' cand --min-ratio 'Minimal size proportion required to appear' - cand --threads 'Set the maximum number of threads to spawn. Could be either "auto", "max", or a number' + cand --threads 'Set the maximum number of threads to spawn. Could be either "auto", "max", or a positive integer' cand --json-input 'Read JSON data from stdin' cand --json-output 'Print JSON data instead of an ASCII chart' cand -H 'Detect and subtract the sizes of hardlinks from their parent directory totals' diff --git a/exports/completion.fish b/exports/completion.fish index 74ceb5b..41cc644 100644 --- a/exports/completion.fish +++ b/exports/completion.fish @@ -8,7 +8,7 @@ complete -c pdu -s d -l max-depth -l depth -d 'Maximum depth to display the data complete -c pdu -s w -l total-width -l width -d 'Width of the visualization' -r complete -c pdu -l column-width -d 'Maximum widths of the tree column and width of the bar column' -r complete -c pdu -s m -l min-ratio -d 'Minimal size proportion required to appear' -r -complete -c pdu -l threads -d 'Set the maximum number of threads to spawn. Could be either "auto", "max", or a number' -r +complete -c pdu -l threads -d 'Set the maximum number of threads to spawn. Could be either "auto", "max", or a positive integer' -r complete -c pdu -l json-input -d 'Read JSON data from stdin' complete -c pdu -l json-output -d 'Print JSON data instead of an ASCII chart' complete -c pdu -s H -l deduplicate-hardlinks -l detect-links -l dedupe-links -d 'Detect and subtract the sizes of hardlinks from their parent directory totals' diff --git a/exports/completion.ps1 b/exports/completion.ps1 index 3c1a31e..8814bf7 100644 --- a/exports/completion.ps1 +++ b/exports/completion.ps1 @@ -34,7 +34,7 @@ Register-ArgumentCompleter -Native -CommandName 'pdu' -ScriptBlock { [CompletionResult]::new('--column-width', '--column-width', [CompletionResultType]::ParameterName, 'Maximum widths of the tree column and width of the bar column') [CompletionResult]::new('-m', '-m', [CompletionResultType]::ParameterName, 'Minimal size proportion required to appear') [CompletionResult]::new('--min-ratio', '--min-ratio', [CompletionResultType]::ParameterName, 'Minimal size proportion required to appear') - [CompletionResult]::new('--threads', '--threads', [CompletionResultType]::ParameterName, 'Set the maximum number of threads to spawn. Could be either "auto", "max", or a number') + [CompletionResult]::new('--threads', '--threads', [CompletionResultType]::ParameterName, 'Set the maximum number of threads to spawn. Could be either "auto", "max", or a positive integer') [CompletionResult]::new('--json-input', '--json-input', [CompletionResultType]::ParameterName, 'Read JSON data from stdin') [CompletionResult]::new('--json-output', '--json-output', [CompletionResultType]::ParameterName, 'Print JSON data instead of an ASCII chart') [CompletionResult]::new('-H', '-H ', [CompletionResultType]::ParameterName, 'Detect and subtract the sizes of hardlinks from their parent directory totals') diff --git a/exports/completion.zsh b/exports/completion.zsh index 1b30b4b..dec1cef 100644 --- a/exports/completion.zsh +++ b/exports/completion.zsh @@ -36,7 +36,7 @@ block-count\:"Count numbers of blocks"))' \ '*--column-width=[Maximum widths of the tree column and width of the bar column]:TREE_WIDTH:_default:TREE_WIDTH:_default' \ '-m+[Minimal size proportion required to appear]:MIN_RATIO:_default' \ '--min-ratio=[Minimal size proportion required to appear]:MIN_RATIO:_default' \ -'--threads=[Set the maximum number of threads to spawn. Could be either "auto", "max", or a number]:THREADS:_default' \ +'--threads=[Set the maximum number of threads to spawn. Could be either "auto", "max", or a positive integer]:THREADS:_default' \ '(-q --quantity -H --deduplicate-hardlinks)--json-input[Read JSON data from stdin]' \ '--json-output[Print JSON data instead of an ASCII chart]' \ '-H[Detect and subtract the sizes of hardlinks from their parent directory totals]' \ diff --git a/src/app.rs b/src/app.rs index c8d8905..7fad5b5 100644 --- a/src/app.rs +++ b/src/app.rs @@ -145,7 +145,7 @@ impl App { } } Threads::Max => None, - Threads::Fixed(threads) => Some(threads), + Threads::Fixed(threads) => Some(threads.get()), }; if let Some(threads) = threads { diff --git a/src/args.rs b/src/args.rs index 19951e4..db6698c 100644 --- a/src/args.rs +++ b/src/args.rs @@ -159,7 +159,7 @@ pub struct Args { #[clap(long, short)] pub progress: bool, - /// Set the maximum number of threads to spawn. Could be either "auto", "max", or a number. + /// Set the maximum number of threads to spawn. Could be either "auto", "max", or a positive integer. #[clap(long, default_value_t = Threads::Auto)] pub threads: Threads, diff --git a/src/args/threads.rs b/src/args/threads.rs index e21a754..44dc44a 100644 --- a/src/args/threads.rs +++ b/src/args/threads.rs @@ -1,5 +1,8 @@ use derive_more::{Display, Error}; -use std::{num::ParseIntError, str::FromStr}; +use std::{ + num::{NonZeroUsize, ParseIntError}, + str::FromStr, +}; const AUTO: &str = "auto"; const MAX: &str = "max"; @@ -12,7 +15,7 @@ pub enum Threads { Auto, #[display("{MAX}")] Max, - Fixed(usize), + Fixed(NonZeroUsize), } /// Error that occurs when parsing a string to as [`Threads`].