Skip to content

Commit

Permalink
Include improvements from branch 'feature/CmdArgs-improved'
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosbento committed Sep 22, 2023
2 parents d88a123 + a4e2127 commit 8143bfa
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 41 deletions.
14 changes: 6 additions & 8 deletions src/eckit/option/CmdArgs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
/// @date March 2016


#include "eckit/option/CmdArgs.h"

#include <iostream>
#include <map>

#include "eckit/exception/Exceptions.h"
#include "eckit/option/CmdArgs.h"
#include "eckit/option/Option.h"
#include "eckit/runtime/Main.h"
#include "eckit/utils/StringTools.h"

namespace eckit::option {

Expand Down Expand Up @@ -87,7 +87,7 @@ void CmdArgs::init(std::function<void(const std::string&)> usage, int args_count
// ... and tokenize [<name>(,<tail>)]
std::vector<std::string> tokens = split_at(a, '=');

std::string name = tokens[0];
const std::string name = tokens[0];
tokens.erase(tokens.begin());

if (auto found = opts.find(name); found != opts.end()) {
Expand All @@ -108,7 +108,7 @@ void CmdArgs::init(std::function<void(const std::string&)> usage, int args_count
i += static_cast<int>(consumed - tokens.size());
}
catch (UserError&) {
Log::info() << "Invalid value for option --" << tokens[0] << std::endl;
Log::info() << "Invalid value for option --" << name << std::endl;
error = true;
}
}
Expand Down Expand Up @@ -143,11 +143,9 @@ void CmdArgs::init(std::function<void(const std::string&)> usage, int args_count
if (options_.size()) {
Log::info() << std::endl;
Log::info() << "Options are:" << std::endl;
Log::info() << "===========:" << std::endl
<< std::endl;
Log::info() << "===========:" << std::endl << std::endl;
for (const Option* j : options_) {
Log::info() << *j << std::endl
<< std::endl;
Log::info() << *j << std::endl << std::endl;
}
Log::info() << std::endl;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/option/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
foreach( TESTCASE RANGE 1 36 )
foreach( TESTCASE RANGE 1 37 )
ecbuild_add_test(
TARGET eckit_test_option_cmdargs_${TESTCASE}
SOURCES eckit_test_option_cmdargs.cc
Expand Down
Loading

0 comments on commit 8143bfa

Please sign in to comment.