sharkdp / hexyl

A command-line hex viewer
Apache License 2.0
8.93k stars 227 forks source link

Please use (or support) -c for byte count #46

Closed FauxFaux closed 5 years ago

FauxFaux commented 5 years ago

hexyl -n 100 is, in my mind, replacing head -c 100 | xxd. If it is directly replacing xxd, xxd calls this option -l (length, which I had to look up, because I use head).

Please support -c, with the same behaviour as the current -n, and/or improve the error output to remind users of the correct option:

% hexyl -c 257 /dev/urandom
error: Found argument '-c' which wasn't expected, or isn't valid in this context

USAGE:
    hexyl [file]

For more information try --help

Annoyingly, xxd uses -c for cols.

sharkdp commented 5 years ago

I used -n for --length because that is used in hexdump. I'm okay with adding an additional alias -c.

selfup commented 5 years ago

I made a small PR, but multiple shortnames does not seem to be an option for clap.

I made some suggestions, but otherwise --c would be the easiest compromise 🙏

sharkdp commented 5 years ago

@selfup Thanks for looking into this. That's a pitty. Maybe this is something that should be requested in clap.

I made some suggestions, but otherwise --c would be the easiest compromise

I'm not a big fan of adding --c, to be honest. Long -- options should be used for descriptive names.

There is a possibility to hide options in clap, so I guess we could go with your other idea and just add a second option which could be hidden.

selfup commented 5 years ago

Yea hiding the --c so we can get a -c would be interesting. If I have time I'll see what can be done about an upstream to clap. Otherwise I will attempt to hide the long "fakename"

We could also have a longname like "count" that would be a viable longname

All I would need to do is: hidden(true); in the Arg definition for long("c")

Let me know if hiding works for now until a change in clap can be made/suggested with approval

selfup commented 5 years ago

Ok updated my PR: https://github.com/sharkdp/hexyl/pull/48#issuecomment-460449756

🎉

selfup commented 5 years ago

Let me know if those PRs resolved the issue @FauxFaux :smile: