29 lines
591 B
C++
29 lines
591 B
C++
#include <os/ArgumentParser.h>
|
|
#include <os/File.h>
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
Result<int> luna_main(int argc, char** argv)
|
|
{
|
|
StringView pathname;
|
|
|
|
os::ArgumentParser parser;
|
|
parser.add_positional_argument(pathname, "path"_sv, true);
|
|
parser.parse(argc, argv);
|
|
|
|
auto file = TRY(os::File::open_or_create(pathname, os::File::WriteOnly));
|
|
|
|
char buffer[4096];
|
|
|
|
while (1)
|
|
{
|
|
char* rc = fgets(buffer, sizeof(buffer), stdin);
|
|
if (rc == 0) break;
|
|
TRY(file->write(StringView { buffer }));
|
|
}
|
|
|
|
return 0;
|
|
}
|