mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 13:36:13 +03:00
Utilities: Use new ArgsParser method for enum values
This commit is contained in:
parent
f71d74ed65
commit
34940821f6
Notes:
sideshowbarker
2024-07-16 20:31:50 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/34940821f6 Pull-request: https://github.com/SerenityOS/serenity/pull/21216 Reviewed-by: https://github.com/gmta ✅
@ -121,26 +121,8 @@ ErrorOr<int> serenity_main(Main::Arguments args)
|
||||
return true;
|
||||
},
|
||||
});
|
||||
args_parser.add_option(Core::ArgsParser::Option {
|
||||
.argument_mode = Core::ArgsParser::OptionArgumentMode::None,
|
||||
.help_string = "Treat binary files as text (same as --binary-mode text)",
|
||||
.long_name = "text",
|
||||
.short_name = 'a',
|
||||
.accept_value = [&](auto) {
|
||||
binary_mode = BinaryFileMode::Text;
|
||||
return true;
|
||||
},
|
||||
});
|
||||
args_parser.add_option(Core::ArgsParser::Option {
|
||||
.argument_mode = Core::ArgsParser::OptionArgumentMode::None,
|
||||
.help_string = "Ignore binary files (same as --binary-mode skip)",
|
||||
.long_name = nullptr,
|
||||
.short_name = 'I',
|
||||
.accept_value = [&](auto) {
|
||||
binary_mode = BinaryFileMode::Skip;
|
||||
return true;
|
||||
},
|
||||
});
|
||||
args_parser.add_option(binary_mode, BinaryFileMode::Text, "Treat binary files as text (same as --binary-mode text)", "text", 'a');
|
||||
args_parser.add_option(binary_mode, BinaryFileMode::Skip, "Ignore binary files (same as --binary-mode skip)", nullptr, 'I');
|
||||
args_parser.add_option(Core::ArgsParser::Option {
|
||||
.argument_mode = Core::ArgsParser::OptionArgumentMode::Required,
|
||||
.help_string = "When to use colored output for the matching text ([auto], never, always)",
|
||||
|
@ -114,22 +114,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
args_parser.add_option(flag_ignore_backups, "Do not list implied entries ending with ~", "ignore-backups", 'B');
|
||||
args_parser.add_option(flag_list_directories_only, "List directories themselves, not their contents", "directory", 'd');
|
||||
args_parser.add_option(flag_long, "Display long info", "long", 'l');
|
||||
args_parser.add_option(Core::ArgsParser::Option {
|
||||
.argument_mode = Core::ArgsParser::OptionArgumentMode::None,
|
||||
.help_string = "Sort files by timestamp (newest first)",
|
||||
.short_name = 't',
|
||||
.accept_value = [](StringView) {
|
||||
flag_sort_by = FieldToSortBy::ModifiedAt;
|
||||
return true;
|
||||
} });
|
||||
args_parser.add_option(Core::ArgsParser::Option {
|
||||
.argument_mode = Core::ArgsParser::OptionArgumentMode::None,
|
||||
.help_string = "Sort files by size (largest first)",
|
||||
.short_name = 'S',
|
||||
.accept_value = [](StringView) {
|
||||
flag_sort_by = FieldToSortBy::Size;
|
||||
return true;
|
||||
} });
|
||||
args_parser.add_option(flag_sort_by, FieldToSortBy::ModifiedAt, "Sort files by timestamp (newest first)", nullptr, 't');
|
||||
args_parser.add_option(flag_sort_by, FieldToSortBy::Size, "Sort files by size (largest first)", nullptr, 'S');
|
||||
args_parser.add_option(flag_reverse_sort, "Reverse sort order", "reverse", 'r');
|
||||
args_parser.add_option(flag_classify, "Append a file type indicator to entries", "classify", 'F');
|
||||
args_parser.add_option(flag_colorize, "Use pretty colors", nullptr, 'G');
|
||||
|
@ -118,15 +118,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
}
|
||||
return true;
|
||||
} });
|
||||
args_parser.add_option({ Core::ArgsParser::OptionArgumentMode::None,
|
||||
"Equivalent to specifying -t o.",
|
||||
nullptr,
|
||||
'o',
|
||||
nullptr,
|
||||
[&string_offset_format](auto) {
|
||||
string_offset_format = StringOffsetFormat::Octal;
|
||||
return true;
|
||||
} });
|
||||
args_parser.add_option(string_offset_format, StringOffsetFormat::Octal, "Equivalent to specifying -t o.", nullptr, 'o');
|
||||
args_parser.set_general_help("Write the sequences of printable characters in files or pipes to stdout.");
|
||||
args_parser.add_positional_argument(paths, "File path", "path", Core::ArgsParser::Required::No);
|
||||
args_parser.parse(arguments);
|
||||
|
Loading…
Reference in New Issue
Block a user