Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into read-s3
Browse files Browse the repository at this point in the history
  • Loading branch information
hobu committed Apr 13, 2016
2 parents 37818c3 + 756cffd commit 0663829
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions include/pdal/util/ProgramArgs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,13 @@ class TArg : public Arg
*/
virtual void setValue(const std::string& s)
{
if (m_set)
{
std::ostringstream oss;
oss << "Attempted to set value twice for argument '" <<
m_longname << "'.";
throw arg_error(oss.str());
}
if (s.size() && s[0] == '-')
{
std::stringstream oss;
Expand Down
3 changes: 3 additions & 0 deletions src/Kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,10 @@ void Kernel::doSwitches(int argc, const char *argv[], ProgramArgs& args)
args.parseSimple(stringArgs);
addSwitches(args);
if (!m_showHelp)
{
args.reset();
args.parse(stringArgs);
}
}
catch (arg_error& e)
{
Expand Down
5 changes: 5 additions & 0 deletions test/unit/ProgramArgsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,25 @@ TEST(ProgramArgsTest, t1)
EXPECT_THROW(args.parse(s), arg_error);

s = toStringList("--foo=TestFoo");
args.reset();
args.parse(s);
EXPECT_EQ(m_foo, "TestFoo");

s = toStringList("--foo TestBar");
args.reset();
args.parse(s);
EXPECT_EQ(m_foo, "TestBar");

s = toStringList("-f");
args.reset();
EXPECT_THROW(args.parse(s), arg_error);

s = toStringList("-f -g");
args.reset();
EXPECT_THROW(args.parse(s), arg_error);

s = toStringList("-f Gah");
args.reset();
args.parse(s);
EXPECT_EQ(m_foo, "Gah");
}
Expand Down

0 comments on commit 0663829

Please sign in to comment.