diff --git a/src/bin/hexyl.rs b/src/bin/hexyl.rs index a27e6e8..3a45603 100644 --- a/src/bin/hexyl.rs +++ b/src/bin/hexyl.rs @@ -331,6 +331,28 @@ fn run() -> Result<(), AnyhowError> { } }; + + 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 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) } else if let Some(panels) = matches