openMSX
CLIOption.cc
Go to the documentation of this file.
1 #include "CLIOption.hh"
2 #include "MSXException.hh"
3 #include <utility>
4 
5 using std::string;
6 
7 namespace openmsx {
8 
9 // class CLIOption
10 
11 string CLIOption::getArgument(const string& option, span<string>& cmdLine) const
12 {
13  if (cmdLine.empty()) {
14  throw FatalError("Missing argument for option \"", option, '\"');
15  }
16  string argument = std::move(cmdLine.front());
17  cmdLine = cmdLine.subspan(1);
18  return argument;
19 }
20 
21 string CLIOption::peekArgument(const span<string>& cmdLine) const
22 {
23  return cmdLine.empty() ? string{} : cmdLine.front();
24 }
25 
26 } // namespace openmsx
std::string peekArgument(const span< std::string > &cmdLine) const
Definition: CLIOption.cc:21
Definition: span.hh:34
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
std::string getArgument(const std::string &option, span< std::string > &cmdLine) const
Definition: CLIOption.cc:11