mirror of
https://github.com/sharkdp/hexyl.git
synced 2026-10-26 20:16:31 +00:00
Account for new panel arguments
This commit is contained in:
1 parent
e6000a56f4
commit
fc794b290c
1 file changed
+7
-23
+7
-23
@@ -390,7 +390,11 @@ fn run() -> Result<(), AnyhowError> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let panels = if matches.get_one::<String>("panels").map(String::as_ref) == Some("auto") {
|
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
|
} else if let Some(panels) = matches
|
||||||
.get_one::<String>("panels")
|
.get_one::<String>("panels")
|
||||||
.map(|s| {
|
.map(|s| {
|
||||||
@@ -412,32 +416,11 @@ fn run() -> Result<(), AnyhowError> {
|
|||||||
})
|
})
|
||||||
.transpose()?
|
.transpose()?
|
||||||
{
|
{
|
||||||
max_panels_fn(terminal_width)
|
max_panels_fn(terminal_width, base_digits, group_bytes.into())
|
||||||
} else {
|
} else {
|
||||||
2
|
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 stdout = io::stdout();
|
||||||
let mut stdout_lock = BufWriter::new(stdout.lock());
|
let mut stdout_lock = BufWriter::new(stdout.lock());
|
||||||
|
|
||||||
@@ -449,6 +432,7 @@ fn run() -> Result<(), AnyhowError> {
|
|||||||
.enable_squeezing(squeeze)
|
.enable_squeezing(squeeze)
|
||||||
.num_panels(panels)
|
.num_panels(panels)
|
||||||
.num_group_bytes(group_bytes)
|
.num_group_bytes(group_bytes)
|
||||||
|
.with_base(base)
|
||||||
.build();
|
.build();
|
||||||
printer.display_offset(skip_offset + display_offset);
|
printer.display_offset(skip_offset + display_offset);
|
||||||
printer.print_all(&mut reader).map_err(|e| anyhow!(e))?;
|
printer.print_all(&mut reader).map_err(|e| anyhow!(e))?;
|
||||||
|
|||||||
Reference in new issue
Block a user