| 11 | static fextl::string Version = "FEX-Emu (" GIT_DESCRIBE_STRING ") "; |
| 12 | |
| 13 | FEXServerOptions Load(int argc, char** argv) { |
| 14 | FEXServerOptions FEXOptions {}; |
| 15 | optparse::OptionParser Parser = optparse::OptionParser().version(Version); |
| 16 | |
| 17 | Parser.add_option("-k", "--kill").action("store_true").set_default(false).help("Shutdown an already active FEXServer"); |
| 18 | |
| 19 | Parser.add_option("-f", "--foreground").action("store_true").set_default(false).help("Run this FEXServer in the foreground"); |
| 20 | |
| 21 | Parser.add_option("-p", "--persistent").action("store").type("int").set_default(0).set_optional_value(true).metavar("n").help("Make FEXServer persistent. Optional number of seconds"); |
| 22 | |
| 23 | Parser.add_option("-w", "--wait").action("store_true").set_default(false).help("Wait for the FEXServer to shutdown"); |
| 24 | Parser.add_option("--wait_pipe").action("store").type("int").set_default(-1).set_optional_value(true); |
| 25 | |
| 26 | Parser.add_option("-v").action("version").help("Version string"); |
| 27 | |
| 28 | optparse::Values Options = Parser.parse_args(argc, argv); |
| 29 | |
| 30 | FEXOptions.Kill = Options.get("kill"); |
| 31 | FEXOptions.Foreground = Options.get("foreground"); |
| 32 | FEXOptions.Wait = Options.get("wait"); |
| 33 | if (FEXOptions.Wait) { |
| 34 | FEXOptions.Foreground = true; |
| 35 | } |
| 36 | FEXOptions.PersistentTimeout = Options.get("persistent"); |
| 37 | |
| 38 | int WaitPipe = Options.get("wait_pipe"); |
| 39 | if (WaitPipe != -1) { |
| 40 | PipeScanner::SetWaitPipe(WaitPipe); |
| 41 | } |
| 42 | return FEXOptions; |
| 43 | } |
| 44 | } // namespace FEXServer::Config |