mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:47:34 +00:00
basename: Port to LibMain
This commit is contained in:
parent
430e231f5e
commit
d7336879d1
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