Skip to content

Conversation

sharifhsn
Copy link
Contributor

Fixes #147.

This PR provides the new --base/-b argument which specifies the base that the bytes should be printed in. The base options exposed by the standard library are binary, octal, decimal, and hexadecimal. If we were to add more options, then we would need to pull in some kind of dependency.

For ease of use, the argument accepts either a number (2, 8, 10, 16), a single character abbreviation (b, o, d, x), a three-character abbreviation (bin, oct, dec, hex), or the full base name (binary, octal, decimal, hexadecimal).

Part of this PR is adjusting the --panels=auto option to account for both base and byte grouping from #170. Now it is guaranteed to give the correct number of panels regardless of options.

I have also added a simple integration test.

Questions for review:

  • Should more bases be allowed?
  • What should the help text suggest for the argument format?
  • Should there be more tests?

This will be my last PR until the next release of hexyl.

@sharkdp
Copy link
Owner

sharkdp commented Dec 4, 2022

Should more bases be allowed?

I think the supported set is completely reasonable. I don't expect anyone to require base 5 or similar.

What should the help text suggest for the argument format?

You're talking about the value_name? I think B is fine. Maybe for the values, we could support either the name (hexadecimal) or a number (16), but that's not really important for now. I'm completely fine with your proposal.

It seems pretty obvious, but maybe we could mention the default (hexadecimal).

Should there be more tests?

I think we're good for now - thank you!

Copy link
Owner

@sharkdp sharkdp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@sharkdp sharkdp merged commit 9770b89 into sharkdp:master Dec 5, 2022
@sharifhsn sharifhsn deleted the base branch December 6, 2022 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Decimal values in place of the hex characters
2 participants