mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-29 13:46:31 +00:00
basename: Port to LibMain
This commit is contained in:
parent
430e231f5e
commit
d7336879d1
Notes:
sideshowbarker
2024-07-18 00:40:13 +09:00
Author: https://github.com/kennethmyhra
Commit: d7336879d1
Pull-request: https://github.com/SerenityOS/serenity/pull/11077
2 changed files with 6 additions and 8 deletions
|
@ -6,15 +6,12 @@
|
|||
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibMain/Main.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
{
|
||||
if (pledge("stdio", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
return 1;
|
||||
}
|
||||
TRY(Core::System::pledge("stdio", nullptr));
|
||||
|
||||
StringView path;
|
||||
StringView suffix;
|
||||
|
@ -22,7 +19,7 @@ int main(int argc, char** argv)
|
|||
Core::ArgsParser args_parser;
|
||||
args_parser.add_positional_argument(path, "Path to get basename from", "path");
|
||||
args_parser.add_positional_argument(suffix, "Suffix to strip from name", "suffix", Core::ArgsParser::Required::No);
|
||||
args_parser.parse(argc, argv);
|
||||
args_parser.parse(arguments);
|
||||
|
||||
auto result = LexicalPath::basename(path);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue