Ignore:
Timestamp:
Sep 2, 2008, 4:57:50 PM (13 years ago)
Author:
Peter
Message:

fixes #413

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/utility/CommandLine.cc

    r1466 r1468  
    4545
    4646  CommandLine::CommandLine(std::string str)
    47     : description_(str)
     47    : description_(str), free_arg_max_(0)
    4848  {}
    4949
     
    8383        long_options_.find(no_name)==long_options_.end())
    8484      long_options_[no_name] = &option;
     85  }
     86
     87
     88  void CommandLine::allow_free_args(size_t n)
     89  {
     90    free_arg_max_ = n;
    8591  }
    8692
     
    155161        else {
    156162          free_arg_.push_back(*arg);
    157           std::stringstream ss;
    158           ss << ": invalid option -- " << *arg << "\n"
    159              << try_help() << "\n";
    160           throw cmd_error(ss.str());
    161          
     163          if (free_arg_.size()>free_arg_max_) {
     164            std::stringstream ss;
     165            ss << ": invalid option -- " << *arg << "\n"
     166               << try_help() << "\n";
     167            throw cmd_error(ss.str());
     168          }
    162169        }
    163170      }
Note: See TracChangeset for help on using the changeset viewer.