-
-
Notifications
You must be signed in to change notification settings - Fork 233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support both little and big endian dump #189
Conversation
src/bin/hexyl.rs
Outdated
.arg( | ||
Arg::new("little_endian_dump") | ||
.short('e') | ||
.action(ArgAction::SetTrue) | ||
.help( | ||
"Print out the data in little endian format. Otherwise the data will be showed \ | ||
in big endian format by default.", | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this only usable with --group-size
? If so, we should specify that using https://docs.rs/clap/latest/clap/struct.Arg.html#method.requires.
Also, should we maybe introduce a --endianness=little/big
option instead (where we can still discuss what the default should be)? We could potentially still have -e
as an alias for --endianness=little
if we choose big
as the default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this option doesn't have to be depending on --group-size
. Because if we don't specify the group size in the option, we'll default it to one. In other words, hexyl -g 1 file
and hexyl file
are the same.
For another question, the reason that I choose to use big-endian as default is because of the design of xxd
:
$ xxd --help
...
Options:
-e little-endian dump (incompatible with -ps,-i,-r).
However, it would be fine if hexyl
want to have a different design for the dump of endianness. Please tell me which you would prefer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this option doesn't have to be depending on --group-size. Because if we don't specify the group size in the option, we'll default it to one. In other words, hexyl -g 1 file and hexyl file are the same.
yes. But Endianness won't have any effect if the group size is 1, right?
However, it would be fine if hexyl want to have a different design for the dump of endianness. Please tell me which you would prefer.
Let's follow xxd here for now, but I would still prefer a --endianness=little/big
option instead of a --little-endian-dump
flag.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But Endianness won't have any effect if the group size is 1, right?
Sure. If we want to inform the user that this would be no effect, let's use the requires method.
Let's follow xxd here for now, but I would still prefer a --endianness=little/big option instead of a --little-endian-dump flag.
I change the command line option to --endianness=little/big
now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about it again and now think that your initial version was actually better (sorry). Because not using requires
allows someone to set an alias like alias hexyl="hexyl --endianness=little"
, and use that even if -g
is not present.
Instead, we can mention that it only has an effect if group size > 1.
I'll make the necessary adjustments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much! This looks good.
In #170, we solve a part of the demand for #104, which provided the option to group bytes. In this patch, I am trying to complete the remaining requirement for endianness.