dirname: Add support for multiple paths

This commit is contained in:
Tim Ledbetter 2023-06-22 18:19:00 +01:00 committed by Tim Flynn
parent 828caf12a6
commit e259c3b38a

View file

@ -12,13 +12,15 @@
ErrorOr<int> serenity_main(Main::Arguments arguments)
{
bool null_terminated = false;
DeprecatedString path;
Vector<DeprecatedString> paths;
Core::ArgsParser args_parser;
args_parser.add_option(null_terminated, "End each output line with \\0, rather than \\n", "zero", 'z');
args_parser.add_positional_argument(path, "Path", "path");
args_parser.add_positional_argument(paths, "Path", "path");
args_parser.parse(arguments);
auto const delimiter = null_terminated ? '\0' : '\n';
out("{}{}", LexicalPath::dirname(path), delimiter);
for (auto const& path : paths)
out("{}{}", LexicalPath::dirname(path), delimiter);
return 0;
}