1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 05:57:44 +00:00

Hexdump: Add verbose option

Verbose option overrides the default coalescing
behaviour by displaying the complete output.
This commit is contained in:
Pankaj Raghav 2021-11-19 11:24:46 +05:30 committed by Ali Mohammad Pur
parent d72158045c
commit 0e873464ed

View file

@ -22,7 +22,9 @@ int main(int argc, char** argv)
{
Core::ArgsParser args_parser;
const char* path = nullptr;
bool verbose = false;
args_parser.add_positional_argument(path, "Input", "input", Core::ArgsParser::Required::No);
args_parser.add_option(verbose, "Display all input data", "verbose", 'v');
args_parser.parse(argc, argv);
@ -79,6 +81,11 @@ int main(int argc, char** argv)
size_t offset;
for (offset = 0; offset + LINE_LENGTH_BYTES - 1 < contents_size; offset += LINE_LENGTH_BYTES) {
if (verbose) {
print_line(&contents[offset], LINE_LENGTH_BYTES);
continue;
}
auto current_line = contents.span().slice(offset, LINE_LENGTH_BYTES);
bool is_same_contents = (current_line == previous_line);
if (!is_same_contents)