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

LibCore: Replace the ArgsParser option argument setting with an enum

Replacement conditions for `requires_argument` have been chosen based
on what would be most convenient for implementing an eventual optional
argument mode.
This commit is contained in:
Tim Schumacher 2022-07-12 22:13:38 +02:00 committed by Linus Groh
parent 810b9daa63
commit 3d51642037
15 changed files with 59 additions and 53 deletions

View file

@ -59,7 +59,7 @@ ErrorOr<int> serenity_main(Main::Arguments args)
args_parser.add_option(recursive, "Recursively scan files", "recursive", 'r');
args_parser.add_option(use_ere, "Extended regular expressions", "extended-regexp", 'E');
args_parser.add_option(Core::ArgsParser::Option {
.requires_argument = true,
.argument_mode = Core::ArgsParser::OptionArgumentMode::Required,
.help_string = "Pattern",
.long_name = "regexp",
.short_name = 'e',
@ -75,7 +75,7 @@ ErrorOr<int> serenity_main(Main::Arguments args)
args_parser.add_option(quiet_mode, "Do not write anything to standard output", "quiet", 'q');
args_parser.add_option(suppress_errors, "Suppress error messages for nonexistent or unreadable files", "no-messages", 's');
args_parser.add_option(Core::ArgsParser::Option {
.requires_argument = true,
.argument_mode = Core::ArgsParser::OptionArgumentMode::Required,
.help_string = "Action to take for binary files ([binary], text, skip)",
.long_name = "binary-mode",
.accept_value = [&](auto* str) {
@ -91,7 +91,7 @@ ErrorOr<int> serenity_main(Main::Arguments args)
},
});
args_parser.add_option(Core::ArgsParser::Option {
.requires_argument = false,
.argument_mode = Core::ArgsParser::OptionArgumentMode::None,
.help_string = "Treat binary files as text (same as --binary-mode text)",
.long_name = "text",
.short_name = 'a',
@ -101,7 +101,7 @@ ErrorOr<int> serenity_main(Main::Arguments args)
},
});
args_parser.add_option(Core::ArgsParser::Option {
.requires_argument = false,
.argument_mode = Core::ArgsParser::OptionArgumentMode::None,
.help_string = "Ignore binary files (same as --binary-mode skip)",
.long_name = nullptr,
.short_name = 'I',
@ -111,7 +111,7 @@ ErrorOr<int> serenity_main(Main::Arguments args)
},
});
args_parser.add_option(Core::ArgsParser::Option {
.requires_argument = true,
.argument_mode = Core::ArgsParser::OptionArgumentMode::Required,
.help_string = "When to use colored output for the matching text ([auto], never, always)",
.long_name = "color",
.short_name = 0,