diff --git a/Userland/Utilities/grep.cpp b/Userland/Utilities/grep.cpp index e73fddafc5..d3f13421d6 100644 --- a/Userland/Utilities/grep.cpp +++ b/Userland/Utilities/grep.cpp @@ -121,26 +121,8 @@ ErrorOr 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)", diff --git a/Userland/Utilities/ls.cpp b/Userland/Utilities/ls.cpp index da342caa29..13a91c746d 100644 --- a/Userland/Utilities/ls.cpp +++ b/Userland/Utilities/ls.cpp @@ -114,22 +114,8 @@ ErrorOr 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'); diff --git a/Userland/Utilities/strings.cpp b/Userland/Utilities/strings.cpp index aa59f1fd58..c82f6cb9a6 100644 --- a/Userland/Utilities/strings.cpp +++ b/Userland/Utilities/strings.cpp @@ -118,15 +118,7 @@ ErrorOr 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);