// Reads bytes from stdin and writes a hexadecimal view like a
no-frills xxd.
// All the actual formatting work is done by format's sweet range
syntax
void main(string[] args)
{
import std.getopt;
uint bytesPerLine = 8;
args.getopt(
"cols|c", &bytesPerLine
);
import std.stdio;
import std.range : chunks;
import std.algorithm : map, copy;
import std.string : format;
import std.ascii : newline;
stdin.byChunk(bytesPerLine)
.map!(bytes => bytes.format!"%(%02X %)%s"(newline))
.copy(stdout.lockingTextWriter());
}