| 1 |
#include "CLIOption.hh" |
| 2 |
|
| 3 |
#include "MSXException.hh" |
| 4 |
|
| 5 |
#include <utility> |
| 6 |
|
| 7 |
namespace openmsx { |
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
std::string CLIOption::getArgument(const std::string& option, std::span<std::string>& cmdLine) |
| 12 |
{ |
| 13 |
if (cmdLine.empty()) { |
| 14 |
throw FatalError("Missing argument for option \"", option, '\"'); |
| 15 |
} |
| 16 |
std::string argument = std::move(cmdLine.front()); |
| 17 |
cmdLine = cmdLine.subspan(1); |
| 18 |
return argument; |
| 19 |
} |
| 20 |
|
| 21 |
std::string CLIOption::peekArgument(const std::span<std::string>& cmdLine) |
| 22 |
{ |
| 23 |
return cmdLine.empty() ? std::string{} : cmdLine.front(); |
| 24 |
} |
| 25 |
|
| 26 |
} |