Set the argument's value from the command-line args. If no value is provided for a required positional option, an arg_error exception is thrown. \note Not intended to be called from user code. \param vals The list of command-line args. */
| 458 | \param vals The list of command-line args. |
| 459 | */ |
| 460 | virtual void assignPositional(ArgValList& vals) |
| 461 | { |
| 462 | if (m_positional == PosType::None || m_set) |
| 463 | return; |
| 464 | for (size_t i = vals.firstUnconsumed(); i < vals.size(); ++i) |
| 465 | { |
| 466 | const std::string& val = vals[i]; |
| 467 | if ((val.size() && val[0] == '-') || vals.consumed(i)) |
| 468 | continue; |
| 469 | setValue(val); |
| 470 | vals.consume(i); |
| 471 | return; |
| 472 | } |
| 473 | if (m_positional == PosType::Required) |
| 474 | throw arg_error("Missing value for positional argument '" + |
| 475 | m_longname + "'."); |
| 476 | } |
| 477 | |
| 478 | /** |
| 479 | Return whether a default value was provided for the argument. |
nothing calls this directly
no test coverage detected