Skip to content

Commit e06f924

Browse files
authored
feat(cli)!: --threads must be positive (#307)
1 parent 737cf89 commit e06f924

File tree

7 files changed

+11
-8
lines changed

7 files changed

+11
-8
lines changed

exports/completion.elv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ set edit:completion:arg-completer[pdu] = {|@words|
3131
cand --column-width 'Maximum widths of the tree column and width of the bar column'
3232
cand -m 'Minimal size proportion required to appear'
3333
cand --min-ratio 'Minimal size proportion required to appear'
34-
cand --threads 'Set the maximum number of threads to spawn. Could be either "auto", "max", or a number'
34+
cand --threads 'Set the maximum number of threads to spawn. Could be either "auto", "max", or a positive integer'
3535
cand --json-input 'Read JSON data from stdin'
3636
cand --json-output 'Print JSON data instead of an ASCII chart'
3737
cand -H 'Detect and subtract the sizes of hardlinks from their parent directory totals'

exports/completion.fish

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ complete -c pdu -s d -l max-depth -l depth -d 'Maximum depth to display the data
88
complete -c pdu -s w -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 -s m -l min-ratio -d 'Minimal size proportion required to appear' -r
11-
complete -c pdu -l threads -d 'Set the maximum number of threads to spawn. Could be either "auto", "max", or a number' -r
11+
complete -c pdu -l threads -d 'Set the maximum number of threads to spawn. Could be either "auto", "max", or a positive integer' -r
1212
complete -c pdu -l json-input -d 'Read JSON data from stdin'
1313
complete -c pdu -l json-output -d 'Print JSON data instead of an ASCII chart'
1414
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'

exports/completion.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Register-ArgumentCompleter -Native -CommandName 'pdu' -ScriptBlock {
3434
[CompletionResult]::new('--column-width', '--column-width', [CompletionResultType]::ParameterName, 'Maximum widths of the tree column and width of the bar column')
3535
[CompletionResult]::new('-m', '-m', [CompletionResultType]::ParameterName, 'Minimal size proportion required to appear')
3636
[CompletionResult]::new('--min-ratio', '--min-ratio', [CompletionResultType]::ParameterName, 'Minimal size proportion required to appear')
37-
[CompletionResult]::new('--threads', '--threads', [CompletionResultType]::ParameterName, 'Set the maximum number of threads to spawn. Could be either "auto", "max", or a number')
37+
[CompletionResult]::new('--threads', '--threads', [CompletionResultType]::ParameterName, 'Set the maximum number of threads to spawn. Could be either "auto", "max", or a positive integer')
3838
[CompletionResult]::new('--json-input', '--json-input', [CompletionResultType]::ParameterName, 'Read JSON data from stdin')
3939
[CompletionResult]::new('--json-output', '--json-output', [CompletionResultType]::ParameterName, 'Print JSON data instead of an ASCII chart')
4040
[CompletionResult]::new('-H', '-H ', [CompletionResultType]::ParameterName, 'Detect and subtract the sizes of hardlinks from their parent directory totals')

exports/completion.zsh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ block-count\:"Count numbers of blocks"))' \
3636
'*--column-width=[Maximum widths of the tree column and width of the bar column]:TREE_WIDTH:_default:TREE_WIDTH:_default' \
3737
'-m+[Minimal size proportion required to appear]:MIN_RATIO:_default' \
3838
'--min-ratio=[Minimal size proportion required to appear]:MIN_RATIO:_default' \
39-
'--threads=[Set the maximum number of threads to spawn. Could be either "auto", "max", or a number]:THREADS:_default' \
39+
'--threads=[Set the maximum number of threads to spawn. Could be either "auto", "max", or a positive integer]:THREADS:_default' \
4040
'(-q --quantity -H --deduplicate-hardlinks)--json-input[Read JSON data from stdin]' \
4141
'--json-output[Print JSON data instead of an ASCII chart]' \
4242
'-H[Detect and subtract the sizes of hardlinks from their parent directory totals]' \

src/app.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ impl App {
145145
}
146146
}
147147
Threads::Max => None,
148-
Threads::Fixed(threads) => Some(threads),
148+
Threads::Fixed(threads) => Some(threads.get()),
149149
};
150150

151151
if let Some(threads) = threads {

src/args.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ pub struct Args {
159159
#[clap(long, short)]
160160
pub progress: bool,
161161

162-
/// Set the maximum number of threads to spawn. Could be either "auto", "max", or a number.
162+
/// Set the maximum number of threads to spawn. Could be either "auto", "max", or a positive integer.
163163
#[clap(long, default_value_t = Threads::Auto)]
164164
pub threads: Threads,
165165

src/args/threads.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
use derive_more::{Display, Error};
2-
use std::{num::ParseIntError, str::FromStr};
2+
use std::{
3+
num::{NonZeroUsize, ParseIntError},
4+
str::FromStr,
5+
};
36

47
const AUTO: &str = "auto";
58
const MAX: &str = "max";
@@ -12,7 +15,7 @@ pub enum Threads {
1215
Auto,
1316
#[display("{MAX}")]
1417
Max,
15-
Fixed(usize),
18+
Fixed(NonZeroUsize),
1619
}
1720

1821
/// Error that occurs when parsing a string to as [`Threads`].

0 commit comments

Comments
 (0)