mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 19:57:36 +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:
parent
810b9daa63
commit
3d51642037
15 changed files with 59 additions and 53 deletions
|
@ -59,7 +59,7 @@ ErrorOr<void> parse_args(Main::Arguments arguments, Vector<String>& files, DuOpt
|
|||
Vector<StringView> files_to_process;
|
||||
|
||||
Core::ArgsParser::Option time_option {
|
||||
true,
|
||||
Core::ArgsParser::OptionArgumentMode::Required,
|
||||
"Show time of type time-type of any file in the directory, or any of its subdirectories. "
|
||||
"Available choices: mtime, modification, ctime, status, use, atime, access",
|
||||
"time",
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -30,7 +30,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
Core::ArgsParser args_parser;
|
||||
|
||||
Core::ArgsParser::Option number_style_option {
|
||||
true,
|
||||
Core::ArgsParser::OptionArgumentMode::Required,
|
||||
"Line numbering style: 't' for non-empty lines, 'a' for all lines, 'n' for no lines",
|
||||
"body-numbering",
|
||||
'b',
|
||||
|
|
|
@ -164,7 +164,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
args_parser.add_option(data, "(HTTP only) Send the provided data via an HTTP POST request", "data", 'd', "data");
|
||||
args_parser.add_option(should_follow_url, "(HTTP only) Follow the Location header if a 3xx status is encountered", "follow", 'l');
|
||||
args_parser.add_option(Core::ArgsParser::Option {
|
||||
.requires_argument = true,
|
||||
.argument_mode = Core::ArgsParser::OptionArgumentMode::Required,
|
||||
.help_string = "Add a header entry to the request",
|
||||
.long_name = "header",
|
||||
.short_name = 'H',
|
||||
|
|
|
@ -35,7 +35,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
args_parser.add_option(wait, "Enable profiling and wait for user input to disable.", nullptr, 'w');
|
||||
args_parser.add_option(cmd_argument, "Command", nullptr, 'c', "command");
|
||||
args_parser.add_option(Core::ArgsParser::Option {
|
||||
true, "Enable tracking specific event type", nullptr, 't', "event_type",
|
||||
Core::ArgsParser::OptionArgumentMode::Required,
|
||||
"Enable tracking specific event type", nullptr, 't', "event_type",
|
||||
[&](String event_type) {
|
||||
seen_event_type_arg = true;
|
||||
if (event_type == "sample")
|
||||
|
|
|
@ -322,7 +322,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
Core::ArgsParser args_parser;
|
||||
args_parser.add_option(Core::ArgsParser::Option {
|
||||
.requires_argument = true,
|
||||
.argument_mode = Core::ArgsParser::OptionArgumentMode::Required,
|
||||
.help_string = "Show progress with OSC 9 (true, false)",
|
||||
.long_name = "show-progress",
|
||||
.short_name = 'p',
|
||||
|
|
|
@ -20,7 +20,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
parser.add_option(permissions, "Apply these permissions going forward", "permissions", 'p', "unveil-permissions");
|
||||
parser.add_option(should_sleep, "Sleep after processing all arguments", "sleep", 's');
|
||||
parser.add_option(Core::ArgsParser::Option {
|
||||
.requires_argument = true,
|
||||
.argument_mode = Core::ArgsParser::OptionArgumentMode::Required,
|
||||
.help_string = "Add a path to the unveil list",
|
||||
.long_name = "unveil",
|
||||
.short_name = 'u',
|
||||
|
@ -37,7 +37,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
return true;
|
||||
} });
|
||||
parser.add_option(Core::ArgsParser::Option {
|
||||
.requires_argument = false,
|
||||
.argument_mode = Core::ArgsParser::OptionArgumentMode::None,
|
||||
.help_string = "Lock the veil",
|
||||
.long_name = "lock",
|
||||
.short_name = 'l',
|
||||
|
|
|
@ -138,7 +138,7 @@ static struct winsize g_window_size;
|
|||
static void parse_args(Main::Arguments arguments, TopOption& top_option)
|
||||
{
|
||||
Core::ArgsParser::Option sort_by_option {
|
||||
true,
|
||||
Core::ArgsParser::OptionArgumentMode::Required,
|
||||
"Sort by field [pid, tid, pri, user, state, virt, phys, cpu, name]",
|
||||
"sort-by",
|
||||
's',
|
||||
|
|
|
@ -288,7 +288,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
parser.add_option(export_all_imports, "Export noop functions corresponding to imports", "export-noop", 0);
|
||||
parser.add_option(shell_mode, "Launch a REPL in the module's context (implies -i)", "shell", 's');
|
||||
parser.add_option(Core::ArgsParser::Option {
|
||||
.requires_argument = true,
|
||||
.argument_mode = Core::ArgsParser::OptionArgumentMode::Required,
|
||||
.help_string = "Extra modules to link with, use to resolve imports",
|
||||
.long_name = "link",
|
||||
.short_name = 'l',
|
||||
|
@ -302,7 +302,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
},
|
||||
});
|
||||
parser.add_option(Core::ArgsParser::Option {
|
||||
.requires_argument = true,
|
||||
.argument_mode = Core::ArgsParser::OptionArgumentMode::Required,
|
||||
.help_string = "Supply arguments to the function (default=0) (expects u64, casts to required type)",
|
||||
.long_name = "arg",
|
||||
.short_name = 0,
|
||||
|
|
|
@ -121,7 +121,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
args_parser.add_option(flag_noheader, "Turn off the header describing the command and interval", "no-title", 't');
|
||||
args_parser.add_option(flag_beep_on_fail, "Beep if the command has a non-zero exit code", "beep", 'b');
|
||||
Core::ArgsParser::Option file_arg {
|
||||
.requires_argument = true,
|
||||
.argument_mode = Core::ArgsParser::OptionArgumentMode::Required,
|
||||
.help_string = "Run command whenever this file changes. Can be used multiple times.",
|
||||
.long_name = "file",
|
||||
.short_name = 'f',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue