Set the argument's value from the command-line args. List-based arguments consume ALL positional arguments until one is found that can't be converted to the type of the bound variable. \note Not intended to be called from user code. \param vals The list of command-line args. */
| 669 | \param vals The list of command-line args. |
| 670 | */ |
| 671 | virtual void assignPositional(ArgValList& vals) |
| 672 | { |
| 673 | if (m_positional == PosType::None || m_set) |
| 674 | return; |
| 675 | |
| 676 | int cnt = 0; |
| 677 | for (size_t i = vals.firstUnconsumed(); i < vals.size(); ++i) |
| 678 | { |
| 679 | const std::string& val = vals[i]; |
| 680 | if ((val.size() && val[0] == '-') || vals.consumed(i)) |
| 681 | continue; |
| 682 | try |
| 683 | { |
| 684 | setValue(val); |
| 685 | vals.consume(i); |
| 686 | cnt++; |
| 687 | } |
| 688 | catch (arg_error&) |
| 689 | { |
| 690 | break; |
| 691 | } |
| 692 | } |
| 693 | if (cnt == 0 && m_positional == PosType::Required) |
| 694 | { |
| 695 | throw arg_error("Missing value for positional argument '" + |
| 696 | m_longname + "'."); |
| 697 | } |
| 698 | } |
| 699 | |
| 700 | /** |
| 701 | Return whether a default value was provided for the argument. |
nothing calls this directly
no test coverage detected