2022-11-06 21:12:30 -08:00
|
|
|
#include <aocpp/Startup.hpp>
|
|
|
|
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <iostream>
|
2022-11-07 21:00:14 -08:00
|
|
|
#include <optional>
|
|
|
|
#include <memory>
|
2022-11-06 21:12:30 -08:00
|
|
|
#include <fstream>
|
|
|
|
|
|
|
|
namespace aocpp {
|
|
|
|
|
2022-11-07 21:00:14 -08:00
|
|
|
auto Startup(int argc, char ** argv) -> std::istream& {
|
|
|
|
static std::ifstream fin;
|
|
|
|
switch (argc) {
|
|
|
|
case 2: fin = std::ifstream{argv[1]}; return fin;
|
|
|
|
case 1: return std::cin;
|
|
|
|
default:
|
|
|
|
std::cerr << "bad arguments\n";
|
2022-11-06 21:12:30 -08:00
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|