mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:07:45 +00:00
LibCore+Everywhere: Remove ArgsParser::add*(char const*&)
This is not guaranteed to always work correctly as ArgsParser deals in StringViews and might have a non-properly-null-terminated string as a value. As a bonus, using StringView (and DeprecatedString where necessary) leads to nicer looking code too :^)
This commit is contained in:
parent
60908adcbe
commit
500044906d
43 changed files with 122 additions and 145 deletions
|
@ -15,14 +15,14 @@
|
|||
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
{
|
||||
Vector<DeprecatedString> paths;
|
||||
char const* opt_algorithm = nullptr;
|
||||
StringView opt_algorithm;
|
||||
|
||||
Core::ArgsParser args_parser;
|
||||
args_parser.add_option(opt_algorithm, "Checksum algorithm (default 'crc32', use 'list' to list available algorithms)", "algorithm", '\0', nullptr);
|
||||
args_parser.add_positional_argument(paths, "File", "file", Core::ArgsParser::Required::No);
|
||||
args_parser.parse(arguments);
|
||||
|
||||
auto algorithm = (opt_algorithm == nullptr) ? "crc32" : DeprecatedString(opt_algorithm).to_lowercase();
|
||||
auto algorithm = opt_algorithm.is_empty() ? "crc32" : DeprecatedString(opt_algorithm).to_lowercase();
|
||||
|
||||
auto available_algorithms = Vector<DeprecatedString> { "crc32", "adler32" };
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue