#include #include #include using os::File; static Result do_cat(StringView path) { SharedPtr f; auto out = File::standard_output(); if (path == "-") f = File::standard_input(); else f = TRY(File::open(path, File::ReadOnly)); while (1) { String line = TRY(f->read_line()); if (line.is_empty()) break; out->write(line.view()); } return {}; } Result luna_main(int argc, char** argv) { StringView filename; os::ArgumentParser parser; parser.add_positional_argument(filename, "file"_sv, "-"_sv); Vector extra_files = TRY(parser.parse(argc, argv)); TRY(do_cat(filename)); for (auto file : extra_files) TRY(do_cat(file)); return 0; }