mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
hexdump: Add an option to specify dump offset
This is very helpful when trying to make sense of large binary files :^)
This commit is contained in:
parent
db27499865
commit
70da5f977b
Notes:
sideshowbarker
2024-07-17 16:23:55 +09:00
Author: https://github.com/kuzux Commit: https://github.com/SerenityOS/serenity/commit/70da5f977b Pull-request: https://github.com/SerenityOS/serenity/pull/17027
1 changed files with 4 additions and 1 deletions
|
@ -29,14 +29,17 @@ ErrorOr<int> serenity_main(Main::Arguments args)
|
|||
StringView path;
|
||||
bool verbose = false;
|
||||
Optional<size_t> max_bytes;
|
||||
Optional<size_t> seek_to;
|
||||
|
||||
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.add_option(max_bytes, "Truncate to a fixed number of bytes", nullptr, 'n', "bytes");
|
||||
|
||||
args_parser.add_option(seek_to, "Seek to a byte offset", "seek", 's', "offset");
|
||||
args_parser.parse(args);
|
||||
|
||||
auto file = TRY(Core::Stream::File::open_file_or_standard_stream(path, Core::Stream::OpenMode::Read));
|
||||
if (seek_to.has_value())
|
||||
TRY(file->seek(seek_to.value(), Core::Stream::SeekMode::SetPosition));
|
||||
|
||||
auto print_line = [](Bytes line) {
|
||||
VERIFY(line.size() <= LINE_LENGTH_BYTES);
|
||||
|
|
Loading…
Reference in a new issue