2020-08-10 21:41:35 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
2023-06-22 20:18:46 +03:00
|
|
|
* Copyright (c) 2023, Tim Ledbetter <timledbetter@gmail.com>
|
2020-08-10 21:41:35 +03:00
|
|
|
*
|
2021-04-22 11:24:48 +03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-08-10 21:41:35 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <AK/LexicalPath.h>
|
|
|
|
#include <LibCore/ArgsParser.h>
|
2021-12-07 23:28:21 +03:00
|
|
|
#include <LibMain/Main.h>
|
2020-08-10 21:41:35 +03:00
|
|
|
|
2021-12-07 23:28:21 +03:00
|
|
|
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
2020-08-10 21:41:35 +03:00
|
|
|
{
|
2023-06-22 20:18:46 +03:00
|
|
|
bool null_terminated = false;
|
2023-12-16 17:19:34 +03:00
|
|
|
Vector<ByteString> paths;
|
2020-08-10 21:41:35 +03:00
|
|
|
Core::ArgsParser args_parser;
|
2023-06-22 20:18:46 +03:00
|
|
|
args_parser.add_option(null_terminated, "End each output line with \\0, rather than \\n", "zero", 'z');
|
2023-06-22 20:19:00 +03:00
|
|
|
args_parser.add_positional_argument(paths, "Path", "path");
|
2021-12-07 23:28:21 +03:00
|
|
|
args_parser.parse(arguments);
|
2020-08-10 21:41:35 +03:00
|
|
|
|
2023-06-22 20:18:46 +03:00
|
|
|
auto const delimiter = null_terminated ? '\0' : '\n';
|
2023-06-22 20:19:00 +03:00
|
|
|
for (auto const& path : paths)
|
|
|
|
out("{}{}", LexicalPath::dirname(path), delimiter);
|
|
|
|
|
2020-08-10 21:41:35 +03:00
|
|
|
return 0;
|
|
|
|
}
|