From fc794b290c5f00c86633da86d1a058982660b694 Mon Sep 17 00:00:00 2001 From: Sharif Haason Date: Sun, 27 Nov 2022 17:19:33 -0500 Subject: [PATCH] Account for new panel arguments --- src/bin/hexyl.rs | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/src/bin/hexyl.rs b/src/bin/hexyl.rs index 1b9dcf5..58cc698 100644 --- a/src/bin/hexyl.rs +++ b/src/bin/hexyl.rs @@ -390,7 +390,11 @@ fn run() -> Result<(), AnyhowError> { }; let panels = if matches.get_one::("panels").map(String::as_ref) == Some("auto") { - max_panels_fn(terminal_size().ok_or_else(|| anyhow!("not a TTY"))?.0 .0 as u64) + max_panels_fn( + terminal_size().ok_or_else(|| anyhow!("not a TTY"))?.0 .0 as u64, + base_digits, + group_bytes.into(), + ) } else if let Some(panels) = matches .get_one::("panels") .map(|s| { @@ -412,32 +416,11 @@ fn run() -> Result<(), AnyhowError> { }) .transpose()? { - max_panels_fn(terminal_width) + max_panels_fn(terminal_width, base_digits, group_bytes.into()) } else { 2 }; - let group_bytes = if let Some(group_bytes) = matches - .get_one::("group_bytes") - .map(|s| { - s.parse::().map(u8::from).context(anyhow!( - "failed to parse `--group-bytes`/`-g` arg {:?} as unsigned nonzero integer", - s - )) - }) - .transpose()? - { - if (group_bytes <= 8) && ((group_bytes & (group_bytes - 1)) == 0) { - group_bytes - } else { - return Err(anyhow!( - "Possible options for the `--group-bytes`/`-g` option are 1, 2, 4 or 8. " - )); - } - } else { - 1 - }; - let stdout = io::stdout(); let mut stdout_lock = BufWriter::new(stdout.lock()); @@ -449,6 +432,7 @@ fn run() -> Result<(), AnyhowError> { .enable_squeezing(squeeze) .num_panels(panels) .num_group_bytes(group_bytes) + .with_base(base) .build(); printer.display_offset(skip_offset + display_offset); printer.print_all(&mut reader).map_err(|e| anyhow!(e))?;