Skip to content

Commit be80dc1

Browse files
authored
Merge pull request #230 from KSXGitHub/default-alignment-to-left
Make left alignment the default alignment
2 parents ef89489 + 3e029a7 commit be80dc1

11 files changed

+35
-35
lines changed

exports/completion.bash

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ _pdu() {
1919

2020
case "${cmd}" in
2121
pdu)
22-
opts="-h -V --json-input --json-output --bytes-format --top-down --align-left --quantity --max-depth --total-width --column-width --min-ratio --no-sort --silent-errors --progress --help --version [FILES]..."
22+
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 --help --version [FILES]..."
2323
if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
2424
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
2525
return 0

exports/completion.elv

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ set edit:completion:arg-completer[pdu] = {|@words|
2727
cand --json-input 'Read JSON data from stdin'
2828
cand --json-output 'Print JSON data instead of an ASCII chart'
2929
cand --top-down 'Print the tree top-down instead of bottom-up'
30-
cand --align-left 'Fill the bars from left to right'
30+
cand --align-right 'Set the root of the bars to the right'
3131
cand --no-sort 'Preserve order of entries'
3232
cand --silent-errors 'Prevent filesystem error messages from appearing in stderr'
3333
cand --progress 'Report progress being made at the expense of performance'

exports/completion.fish

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ complete -c pdu -l min-ratio -d 'Minimal size proportion required to appear' -r
77
complete -c pdu -l json-input -d 'Read JSON data from stdin'
88
complete -c pdu -l json-output -d 'Print JSON data instead of an ASCII chart'
99
complete -c pdu -l top-down -d 'Print the tree top-down instead of bottom-up'
10-
complete -c pdu -l align-left -d 'Fill the bars from left to right'
10+
complete -c pdu -l align-right -d 'Set the root of the bars to the right'
1111
complete -c pdu -l no-sort -d 'Preserve order of entries'
1212
complete -c pdu -l silent-errors -d 'Prevent filesystem error messages from appearing in stderr'
1313
complete -c pdu -l progress -d 'Report progress being made at the expense of performance'

exports/completion.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Register-ArgumentCompleter -Native -CommandName 'pdu' -ScriptBlock {
3030
[CompletionResult]::new('--json-input', 'json-input', [CompletionResultType]::ParameterName, 'Read JSON data from stdin')
3131
[CompletionResult]::new('--json-output', 'json-output', [CompletionResultType]::ParameterName, 'Print JSON data instead of an ASCII chart')
3232
[CompletionResult]::new('--top-down', 'top-down', [CompletionResultType]::ParameterName, 'Print the tree top-down instead of bottom-up')
33-
[CompletionResult]::new('--align-left', 'align-left', [CompletionResultType]::ParameterName, 'Fill the bars from left to right')
33+
[CompletionResult]::new('--align-right', 'align-right', [CompletionResultType]::ParameterName, 'Set the root of the bars to the right')
3434
[CompletionResult]::new('--no-sort', 'no-sort', [CompletionResultType]::ParameterName, 'Preserve order of entries')
3535
[CompletionResult]::new('--silent-errors', 'silent-errors', [CompletionResultType]::ParameterName, 'Prevent filesystem error messages from appearing in stderr')
3636
[CompletionResult]::new('--progress', 'progress', [CompletionResultType]::ParameterName, 'Report progress being made at the expense of performance')

exports/completion.zsh

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ block-count\:"Count numbers of blocks"))' \
2828
'(--quantity)--json-input[Read JSON data from stdin]' \
2929
'--json-output[Print JSON data instead of an ASCII chart]' \
3030
'--top-down[Print the tree top-down instead of bottom-up]' \
31-
'--align-left[Fill the bars from left to right]' \
31+
'--align-right[Set the root of the bars to the right]' \
3232
'--no-sort[Preserve order of entries]' \
3333
'--silent-errors[Prevent filesystem error messages from appearing in stderr]' \
3434
'--progress[Report progress being made at the expense of performance]' \

src/app.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ impl App {
5454
let Args {
5555
bytes_format,
5656
top_down,
57-
align_left,
57+
align_right,
5858
max_depth,
5959
..
6060
} = self.args;
6161
let direction = Direction::from_top_down(top_down);
62-
let bar_alignment = BarAlignment::from_align_left(align_left);
62+
let bar_alignment = BarAlignment::from_align_right(align_right);
6363

6464
let unit_and_tree = stdin()
6565
.pipe(serde_json::from_reader::<_, JsonData>)
@@ -132,7 +132,7 @@ impl App {
132132
json_output,
133133
bytes_format,
134134
top_down,
135-
align_left,
135+
align_right,
136136
max_depth,
137137
min_ratio,
138138
no_sort,
@@ -141,7 +141,7 @@ impl App {
141141
{
142142
return Sub {
143143
direction: Direction::from_top_down(top_down),
144-
bar_alignment: BarAlignment::from_align_left(align_left),
144+
bar_alignment: BarAlignment::from_align_right(align_right),
145145
get_data: $get_data,
146146
reporter: $create_reporter::<$data>(report_error),
147147
bytes_format: $format(bytes_format),

src/args.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ pub struct Args {
9393
#[clap(long)]
9494
pub top_down: bool,
9595

96-
/// Fill the bars from left to right.
96+
/// Set the root of the bars to the right.
9797
#[clap(long)]
98-
pub align_left: bool,
98+
pub align_right: bool,
9999

100100
/// Aspect of the files/directories to be measured.
101101
#[clap(long, value_enum, default_value_t = Quantity::DEFAULT)]

src/visualizer/bar_alignment.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ pub enum BarAlignment {
99

1010
impl BarAlignment {
1111
#[cfg(feature = "cli")]
12-
pub(crate) const fn from_align_left(align_left: bool) -> Self {
13-
if align_left {
14-
BarAlignment::Left
15-
} else {
12+
pub(crate) const fn from_align_right(align_right: bool) -> Self {
13+
if align_right {
1614
BarAlignment::Right
15+
} else {
16+
BarAlignment::Left
1717
}
1818
}
1919
}

tests/cli_errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ fn fs_errors() {
141141
data_tree: &data_tree,
142142
bytes_format: BytesFormat::MetricUnits,
143143
direction: Direction::BottomUp,
144-
bar_alignment: BarAlignment::Right,
144+
bar_alignment: BarAlignment::Left,
145145
column_width_distribution: ColumnWidthDistribution::total(100),
146146
max_depth: 10.try_into().unwrap(),
147147
};

tests/json.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ fn json_input() {
131131
data_tree: &sample_tree(),
132132
bytes_format: BytesFormat::MetricUnits,
133133
direction: Direction::BottomUp,
134-
bar_alignment: BarAlignment::Right,
134+
bar_alignment: BarAlignment::Left,
135135
column_width_distribution: ColumnWidthDistribution::total(100),
136136
max_depth: 10.try_into().unwrap(),
137137
};

tests/usual_cli.rs

+18-18
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ fn total_width() {
5252
data_tree: &data_tree,
5353
bytes_format: BytesFormat::MetricUnits,
5454
direction: Direction::BottomUp,
55-
bar_alignment: BarAlignment::Right,
55+
bar_alignment: BarAlignment::Left,
5656
column_width_distribution: ColumnWidthDistribution::total(100),
5757
max_depth: 10.try_into().unwrap(),
5858
};
@@ -90,7 +90,7 @@ fn column_width() {
9090
data_tree: &data_tree,
9191
bytes_format: BytesFormat::MetricUnits,
9292
direction: Direction::BottomUp,
93-
bar_alignment: BarAlignment::Right,
93+
bar_alignment: BarAlignment::Left,
9494
column_width_distribution: ColumnWidthDistribution::components(10, 90),
9595
max_depth: 10.try_into().unwrap(),
9696
};
@@ -127,7 +127,7 @@ fn min_ratio_0() {
127127
data_tree: &data_tree,
128128
bytes_format: BytesFormat::MetricUnits,
129129
direction: Direction::BottomUp,
130-
bar_alignment: BarAlignment::Right,
130+
bar_alignment: BarAlignment::Left,
131131
column_width_distribution: ColumnWidthDistribution::total(100),
132132
max_depth: 10.try_into().unwrap(),
133133
};
@@ -165,7 +165,7 @@ fn min_ratio() {
165165
data_tree: &data_tree,
166166
bytes_format: BytesFormat::MetricUnits,
167167
direction: Direction::BottomUp,
168-
bar_alignment: BarAlignment::Right,
168+
bar_alignment: BarAlignment::Left,
169169
column_width_distribution: ColumnWidthDistribution::total(100),
170170
max_depth: 10.try_into().unwrap(),
171171
};
@@ -203,7 +203,7 @@ fn max_depth_2() {
203203
data_tree: &data_tree,
204204
bytes_format: BytesFormat::MetricUnits,
205205
direction: Direction::BottomUp,
206-
bar_alignment: BarAlignment::Right,
206+
bar_alignment: BarAlignment::Left,
207207
column_width_distribution: ColumnWidthDistribution::total(100),
208208
max_depth: 2.try_into().unwrap(),
209209
};
@@ -241,7 +241,7 @@ fn max_depth_1() {
241241
data_tree: &data_tree,
242242
bytes_format: BytesFormat::MetricUnits,
243243
direction: Direction::BottomUp,
244-
bar_alignment: BarAlignment::Right,
244+
bar_alignment: BarAlignment::Left,
245245
column_width_distribution: ColumnWidthDistribution::total(100),
246246
max_depth: 1.try_into().unwrap(),
247247
};
@@ -278,7 +278,7 @@ fn top_down() {
278278
data_tree: &data_tree,
279279
bytes_format: BytesFormat::MetricUnits,
280280
direction: Direction::TopDown,
281-
bar_alignment: BarAlignment::Right,
281+
bar_alignment: BarAlignment::Left,
282282
column_width_distribution: ColumnWidthDistribution::total(100),
283283
max_depth: 10.try_into().unwrap(),
284284
};
@@ -290,12 +290,12 @@ fn top_down() {
290290
}
291291

292292
#[test]
293-
fn align_left() {
293+
fn align_right() {
294294
let workspace = SampleWorkspace::default();
295295
let actual = Command::new(PDU)
296296
.with_current_dir(workspace.as_path())
297297
.with_arg("--total-width=100")
298-
.with_arg("--align-left")
298+
.with_arg("--align-right")
299299
.pipe(stdio)
300300
.output()
301301
.expect("spawn command")
@@ -315,7 +315,7 @@ fn align_left() {
315315
data_tree: &data_tree,
316316
bytes_format: BytesFormat::MetricUnits,
317317
direction: Direction::BottomUp,
318-
bar_alignment: BarAlignment::Left,
318+
bar_alignment: BarAlignment::Right,
319319
column_width_distribution: ColumnWidthDistribution::total(100),
320320
max_depth: 10.try_into().unwrap(),
321321
};
@@ -352,7 +352,7 @@ fn quantity_apparent_size() {
352352
data_tree: &data_tree,
353353
bytes_format: BytesFormat::MetricUnits,
354354
direction: Direction::BottomUp,
355-
bar_alignment: BarAlignment::Right,
355+
bar_alignment: BarAlignment::Left,
356356
column_width_distribution: ColumnWidthDistribution::total(100),
357357
max_depth: 10.try_into().unwrap(),
358358
};
@@ -390,7 +390,7 @@ fn quantity_block_size() {
390390
data_tree: &data_tree,
391391
bytes_format: BytesFormat::MetricUnits,
392392
direction: Direction::BottomUp,
393-
bar_alignment: BarAlignment::Right,
393+
bar_alignment: BarAlignment::Left,
394394
column_width_distribution: ColumnWidthDistribution::total(100),
395395
max_depth: 10.try_into().unwrap(),
396396
};
@@ -428,7 +428,7 @@ fn quantity_block_count() {
428428
data_tree: &data_tree,
429429
bytes_format: (),
430430
direction: Direction::BottomUp,
431-
bar_alignment: BarAlignment::Right,
431+
bar_alignment: BarAlignment::Left,
432432
column_width_distribution: ColumnWidthDistribution::total(100),
433433
max_depth: 10.try_into().unwrap(),
434434
};
@@ -467,7 +467,7 @@ fn bytes_format_plain() {
467467
data_tree: &data_tree,
468468
bytes_format: BytesFormat::PlainNumber,
469469
direction: Direction::BottomUp,
470-
bar_alignment: BarAlignment::Right,
470+
bar_alignment: BarAlignment::Left,
471471
column_width_distribution: ColumnWidthDistribution::total(100),
472472
max_depth: 10.try_into().unwrap(),
473473
};
@@ -506,7 +506,7 @@ fn bytes_format_metric() {
506506
data_tree: &data_tree,
507507
bytes_format: BytesFormat::MetricUnits,
508508
direction: Direction::BottomUp,
509-
bar_alignment: BarAlignment::Right,
509+
bar_alignment: BarAlignment::Left,
510510
column_width_distribution: ColumnWidthDistribution::total(100),
511511
max_depth: 10.try_into().unwrap(),
512512
};
@@ -545,7 +545,7 @@ fn bytes_format_binary() {
545545
data_tree: &data_tree,
546546
bytes_format: BytesFormat::BinaryUnits,
547547
direction: Direction::BottomUp,
548-
bar_alignment: BarAlignment::Right,
548+
bar_alignment: BarAlignment::Left,
549549
column_width_distribution: ColumnWidthDistribution::total(100),
550550
max_depth: 10.try_into().unwrap(),
551551
};
@@ -581,7 +581,7 @@ fn path_to_workspace() {
581581
data_tree: &data_tree,
582582
bytes_format: BytesFormat::MetricUnits,
583583
direction: Direction::BottomUp,
584-
bar_alignment: BarAlignment::Right,
584+
bar_alignment: BarAlignment::Left,
585585
column_width_distribution: ColumnWidthDistribution::total(100),
586586
max_depth: 10.try_into().unwrap(),
587587
};
@@ -633,7 +633,7 @@ fn multiple_names() {
633633
data_tree: &data_tree,
634634
bytes_format: BytesFormat::MetricUnits,
635635
direction: Direction::BottomUp,
636-
bar_alignment: BarAlignment::Right,
636+
bar_alignment: BarAlignment::Left,
637637
column_width_distribution: ColumnWidthDistribution::total(100),
638638
max_depth: 10.try_into().unwrap(),
639639
};

0 commit comments

Comments
 (0)