2023-03-29 16:27:02 +00:00
|
|
|
#include <os/ArgumentParser.h>
|
2023-04-12 19:46:10 +00:00
|
|
|
#include <os/File.h>
|
2023-03-29 16:27:02 +00:00
|
|
|
|
2023-03-23 23:52:26 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
2023-03-29 16:27:02 +00:00
|
|
|
StringView pathname;
|
2023-03-23 23:52:26 +00:00
|
|
|
|
2023-04-07 08:40:46 +00:00
|
|
|
os::ArgumentParser parser;
|
2023-04-12 19:46:10 +00:00
|
|
|
parser.add_positional_argument(pathname, "path"_sv, true);
|
2023-03-29 16:27:02 +00:00
|
|
|
parser.parse(argc, argv);
|
2023-03-23 23:52:26 +00:00
|
|
|
|
2023-04-12 19:46:10 +00:00
|
|
|
auto file = os::File::open_or_create(pathname, os::File::WriteOnly).release_value();
|
2023-03-23 23:52:26 +00:00
|
|
|
|
|
|
|
char buffer[4096];
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
char* rc = fgets(buffer, sizeof(buffer), stdin);
|
|
|
|
if (rc == 0) break;
|
2023-04-12 19:46:10 +00:00
|
|
|
file->write(StringView { buffer });
|
2023-03-23 23:52:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|