summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSharif Haason <ssh128@scarletmail.rutgers.edu>2022-11-27 17:19:33 -0500
committerSharif Haason <ssh128@scarletmail.rutgers.edu>2022-11-27 17:19:33 -0500
commitfc794b290c5f00c86633da86d1a058982660b694 (patch)
tree9e1209b90f6a2b39c0c392213fed3999d2c6d3b6
parente6000a56f4ad5cfa5104485a060402ce43c931ee (diff)
Account for new panel arguments
-rw-r--r--src/bin/hexyl.rs30
1 files 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::<String>("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::<String>("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::<String>("group_bytes")
- .map(|s| {
- s.parse::<NonZeroU8>().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))?;