diff --git a/exports/completion.bash b/exports/completion.bash index c4104d78..220e59ec 100644 --- a/exports/completion.bash +++ b/exports/completion.bash @@ -19,7 +19,7 @@ _pdu() { case "${cmd}" in pdu) - 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]..." + 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]..." if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 diff --git a/exports/completion.elv b/exports/completion.elv index 6f357ae0..643c8ea4 100644 --- a/exports/completion.elv +++ b/exports/completion.elv @@ -27,7 +27,7 @@ set edit:completion:arg-completer[pdu] = {|@words| cand --json-input 'Read JSON data from stdin' cand --json-output 'Print JSON data instead of an ASCII chart' cand --top-down 'Print the tree top-down instead of bottom-up' - cand --align-left 'Fill the bars from left to right' + cand --align-right 'Set the root of the bars to the right' cand --no-sort 'Preserve order of entries' cand --silent-errors 'Prevent filesystem error messages from appearing in stderr' cand --progress 'Report progress being made at the expense of performance' diff --git a/exports/completion.fish b/exports/completion.fish index 4d19641b..eef29a30 100644 --- a/exports/completion.fish +++ b/exports/completion.fish @@ -7,7 +7,7 @@ complete -c pdu -l min-ratio -d 'Minimal size proportion required to appear' -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 -l top-down -d 'Print the tree top-down instead of bottom-up' -complete -c pdu -l align-left -d 'Fill the bars from left to right' +complete -c pdu -l align-right -d 'Set the root of the bars to the right' complete -c pdu -l no-sort -d 'Preserve order of entries' complete -c pdu -l silent-errors -d 'Prevent filesystem error messages from appearing in stderr' complete -c pdu -l progress -d 'Report progress being made at the expense of performance' diff --git a/exports/completion.ps1 b/exports/completion.ps1 index 95753b97..6fc68933 100644 --- a/exports/completion.ps1 +++ b/exports/completion.ps1 @@ -30,7 +30,7 @@ Register-ArgumentCompleter -Native -CommandName 'pdu' -ScriptBlock { [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('--top-down', 'top-down', [CompletionResultType]::ParameterName, 'Print the tree top-down instead of bottom-up') - [CompletionResult]::new('--align-left', 'align-left', [CompletionResultType]::ParameterName, 'Fill the bars from left to right') + [CompletionResult]::new('--align-right', 'align-right', [CompletionResultType]::ParameterName, 'Set the root of the bars to the right') [CompletionResult]::new('--no-sort', 'no-sort', [CompletionResultType]::ParameterName, 'Preserve order of entries') [CompletionResult]::new('--silent-errors', 'silent-errors', [CompletionResultType]::ParameterName, 'Prevent filesystem error messages from appearing in stderr') [CompletionResult]::new('--progress', 'progress', [CompletionResultType]::ParameterName, 'Report progress being made at the expense of performance') diff --git a/exports/completion.zsh b/exports/completion.zsh index 80a5e0cf..39fec34b 100644 --- a/exports/completion.zsh +++ b/exports/completion.zsh @@ -28,7 +28,7 @@ block-count\:"Count numbers of blocks"))' \ '(--quantity)--json-input[Read JSON data from stdin]' \ '--json-output[Print JSON data instead of an ASCII chart]' \ '--top-down[Print the tree top-down instead of bottom-up]' \ -'--align-left[Fill the bars from left to right]' \ +'--align-right[Set the root of the bars to the right]' \ '--no-sort[Preserve order of entries]' \ '--silent-errors[Prevent filesystem error messages from appearing in stderr]' \ '--progress[Report progress being made at the expense of performance]' \ diff --git a/src/app.rs b/src/app.rs index e4bc40d4..2221f497 100644 --- a/src/app.rs +++ b/src/app.rs @@ -54,12 +54,12 @@ impl App { let Args { bytes_format, top_down, - align_left, + align_right, max_depth, .. } = self.args; let direction = Direction::from_top_down(top_down); - let bar_alignment = BarAlignment::from_align_left(align_left); + let bar_alignment = BarAlignment::from_align_right(align_right); let unit_and_tree = stdin() .pipe(serde_json::from_reader::<_, JsonData>) @@ -132,7 +132,7 @@ impl App { json_output, bytes_format, top_down, - align_left, + align_right, max_depth, min_ratio, no_sort, @@ -141,7 +141,7 @@ impl App { { return Sub { direction: Direction::from_top_down(top_down), - bar_alignment: BarAlignment::from_align_left(align_left), + bar_alignment: BarAlignment::from_align_right(align_right), get_data: $get_data, reporter: $create_reporter::<$data>(report_error), bytes_format: $format(bytes_format), diff --git a/src/args.rs b/src/args.rs index 544ab8fe..912d2d36 100644 --- a/src/args.rs +++ b/src/args.rs @@ -93,9 +93,9 @@ pub struct Args { #[clap(long)] pub top_down: bool, - /// Fill the bars from left to right. + /// Set the root of the bars to the right. #[clap(long)] - pub align_left: bool, + pub align_right: bool, /// Aspect of the files/directories to be measured. #[clap(long, value_enum, default_value_t = Quantity::DEFAULT)] diff --git a/src/visualizer/bar_alignment.rs b/src/visualizer/bar_alignment.rs index f2c30437..4d425bc7 100644 --- a/src/visualizer/bar_alignment.rs +++ b/src/visualizer/bar_alignment.rs @@ -9,11 +9,11 @@ pub enum BarAlignment { impl BarAlignment { #[cfg(feature = "cli")] - pub(crate) const fn from_align_left(align_left: bool) -> Self { - if align_left { - BarAlignment::Left - } else { + pub(crate) const fn from_align_right(align_right: bool) -> Self { + if align_right { BarAlignment::Right + } else { + BarAlignment::Left } } } diff --git a/tests/cli_errors.rs b/tests/cli_errors.rs index 72efb2b8..4bbb5054 100644 --- a/tests/cli_errors.rs +++ b/tests/cli_errors.rs @@ -141,7 +141,7 @@ fn fs_errors() { data_tree: &data_tree, bytes_format: BytesFormat::MetricUnits, direction: Direction::BottomUp, - bar_alignment: BarAlignment::Right, + bar_alignment: BarAlignment::Left, column_width_distribution: ColumnWidthDistribution::total(100), max_depth: 10.try_into().unwrap(), }; diff --git a/tests/json.rs b/tests/json.rs index 15ef0414..4f647648 100644 --- a/tests/json.rs +++ b/tests/json.rs @@ -131,7 +131,7 @@ fn json_input() { data_tree: &sample_tree(), bytes_format: BytesFormat::MetricUnits, direction: Direction::BottomUp, - bar_alignment: BarAlignment::Right, + bar_alignment: BarAlignment::Left, column_width_distribution: ColumnWidthDistribution::total(100), max_depth: 10.try_into().unwrap(), }; diff --git a/tests/usual_cli.rs b/tests/usual_cli.rs index 1f3df673..17014926 100644 --- a/tests/usual_cli.rs +++ b/tests/usual_cli.rs @@ -52,7 +52,7 @@ fn total_width() { data_tree: &data_tree, bytes_format: BytesFormat::MetricUnits, direction: Direction::BottomUp, - bar_alignment: BarAlignment::Right, + bar_alignment: BarAlignment::Left, column_width_distribution: ColumnWidthDistribution::total(100), max_depth: 10.try_into().unwrap(), }; @@ -90,7 +90,7 @@ fn column_width() { data_tree: &data_tree, bytes_format: BytesFormat::MetricUnits, direction: Direction::BottomUp, - bar_alignment: BarAlignment::Right, + bar_alignment: BarAlignment::Left, column_width_distribution: ColumnWidthDistribution::components(10, 90), max_depth: 10.try_into().unwrap(), }; @@ -127,7 +127,7 @@ fn min_ratio_0() { data_tree: &data_tree, bytes_format: BytesFormat::MetricUnits, direction: Direction::BottomUp, - bar_alignment: BarAlignment::Right, + bar_alignment: BarAlignment::Left, column_width_distribution: ColumnWidthDistribution::total(100), max_depth: 10.try_into().unwrap(), }; @@ -165,7 +165,7 @@ fn min_ratio() { data_tree: &data_tree, bytes_format: BytesFormat::MetricUnits, direction: Direction::BottomUp, - bar_alignment: BarAlignment::Right, + bar_alignment: BarAlignment::Left, column_width_distribution: ColumnWidthDistribution::total(100), max_depth: 10.try_into().unwrap(), }; @@ -203,7 +203,7 @@ fn max_depth_2() { data_tree: &data_tree, bytes_format: BytesFormat::MetricUnits, direction: Direction::BottomUp, - bar_alignment: BarAlignment::Right, + bar_alignment: BarAlignment::Left, column_width_distribution: ColumnWidthDistribution::total(100), max_depth: 2.try_into().unwrap(), }; @@ -241,7 +241,7 @@ fn max_depth_1() { data_tree: &data_tree, bytes_format: BytesFormat::MetricUnits, direction: Direction::BottomUp, - bar_alignment: BarAlignment::Right, + bar_alignment: BarAlignment::Left, column_width_distribution: ColumnWidthDistribution::total(100), max_depth: 1.try_into().unwrap(), }; @@ -278,7 +278,7 @@ fn top_down() { data_tree: &data_tree, bytes_format: BytesFormat::MetricUnits, direction: Direction::TopDown, - bar_alignment: BarAlignment::Right, + bar_alignment: BarAlignment::Left, column_width_distribution: ColumnWidthDistribution::total(100), max_depth: 10.try_into().unwrap(), }; @@ -290,12 +290,12 @@ fn top_down() { } #[test] -fn align_left() { +fn align_right() { let workspace = SampleWorkspace::default(); let actual = Command::new(PDU) .with_current_dir(workspace.as_path()) .with_arg("--total-width=100") - .with_arg("--align-left") + .with_arg("--align-right") .pipe(stdio) .output() .expect("spawn command") @@ -315,7 +315,7 @@ fn align_left() { data_tree: &data_tree, bytes_format: BytesFormat::MetricUnits, direction: Direction::BottomUp, - bar_alignment: BarAlignment::Left, + bar_alignment: BarAlignment::Right, column_width_distribution: ColumnWidthDistribution::total(100), max_depth: 10.try_into().unwrap(), }; @@ -352,7 +352,7 @@ fn quantity_apparent_size() { data_tree: &data_tree, bytes_format: BytesFormat::MetricUnits, direction: Direction::BottomUp, - bar_alignment: BarAlignment::Right, + bar_alignment: BarAlignment::Left, column_width_distribution: ColumnWidthDistribution::total(100), max_depth: 10.try_into().unwrap(), }; @@ -390,7 +390,7 @@ fn quantity_block_size() { data_tree: &data_tree, bytes_format: BytesFormat::MetricUnits, direction: Direction::BottomUp, - bar_alignment: BarAlignment::Right, + bar_alignment: BarAlignment::Left, column_width_distribution: ColumnWidthDistribution::total(100), max_depth: 10.try_into().unwrap(), }; @@ -428,7 +428,7 @@ fn quantity_block_count() { data_tree: &data_tree, bytes_format: (), direction: Direction::BottomUp, - bar_alignment: BarAlignment::Right, + bar_alignment: BarAlignment::Left, column_width_distribution: ColumnWidthDistribution::total(100), max_depth: 10.try_into().unwrap(), }; @@ -467,7 +467,7 @@ fn bytes_format_plain() { data_tree: &data_tree, bytes_format: BytesFormat::PlainNumber, direction: Direction::BottomUp, - bar_alignment: BarAlignment::Right, + bar_alignment: BarAlignment::Left, column_width_distribution: ColumnWidthDistribution::total(100), max_depth: 10.try_into().unwrap(), }; @@ -506,7 +506,7 @@ fn bytes_format_metric() { data_tree: &data_tree, bytes_format: BytesFormat::MetricUnits, direction: Direction::BottomUp, - bar_alignment: BarAlignment::Right, + bar_alignment: BarAlignment::Left, column_width_distribution: ColumnWidthDistribution::total(100), max_depth: 10.try_into().unwrap(), }; @@ -545,7 +545,7 @@ fn bytes_format_binary() { data_tree: &data_tree, bytes_format: BytesFormat::BinaryUnits, direction: Direction::BottomUp, - bar_alignment: BarAlignment::Right, + bar_alignment: BarAlignment::Left, column_width_distribution: ColumnWidthDistribution::total(100), max_depth: 10.try_into().unwrap(), }; @@ -581,7 +581,7 @@ fn path_to_workspace() { data_tree: &data_tree, bytes_format: BytesFormat::MetricUnits, direction: Direction::BottomUp, - bar_alignment: BarAlignment::Right, + bar_alignment: BarAlignment::Left, column_width_distribution: ColumnWidthDistribution::total(100), max_depth: 10.try_into().unwrap(), }; @@ -633,7 +633,7 @@ fn multiple_names() { data_tree: &data_tree, bytes_format: BytesFormat::MetricUnits, direction: Direction::BottomUp, - bar_alignment: BarAlignment::Right, + bar_alignment: BarAlignment::Left, column_width_distribution: ColumnWidthDistribution::total(100), max_depth: 10.try_into().unwrap(), };