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

File tree

11 files changed

+35
-35
lines changed

11 files changed

+35
-35
lines changed

exports/completion.bash

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 4 additions & 4 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 4 additions & 4 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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
};

0 commit comments

Comments
 (0)