[feature] Implement alternate bases #178
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
This will be my last PR until the next release of
hexyl
.