Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare release 5.12.3 #97

Merged
merged 3 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 62 additions & 1 deletion Base/src/ecflow/base/ClientOptionsParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,17 @@ bool is_valid_path(const std::string& path) {
void parse_option(ClientOptionsParser::option_t& option,
ClientOptionsParser::option_set_t& processed_options,
ClientOptionsParser::arguments_set_t& args) {
// We must consider two forms of options:
// 1) --<option> <arg1>
// 2) --<option>=<arg1>

if (auto found = args[0].find('='); found == std::string::npos) {
// In case form 1) is used, we discard the '--<option>'
args.erase(args.begin());
if (args.empty()) {
// This means that the option doesn't actually have a value (i.e. acts as a flag) and we simply return
return;
}
// store the 'arg1'
option.value.push_back(args.front());
option.original_tokens.push_back(args.front());
Expand Down Expand Up @@ -91,6 +99,7 @@ void parse_alter(ClientOptionsParser::option_set_t& processed_options, ClientOpt

ClientOptionsParser::option_t alter{std::string{"alter"}, {}};

// This effectively always collects an argument (i.e. the operation)
parse_option(alter, processed_options, args);

// Collect up to 4 positional arguments, that are not paths
Expand All @@ -109,7 +118,7 @@ void parse_alter(ClientOptionsParser::option_set_t& processed_options, ClientOpt
void parse_label(ClientOptionsParser::option_set_t& processed_options, ClientOptionsParser::arguments_set_t& args) {

// *** Important! ***
// This custom handler is needed to ensure that the "--alter" option
// This custom handler is needed to ensure that the "--label" option
// special value parameters are handled correctly. For example,
// values starting with -, such as "-j64".
//
Expand All @@ -121,6 +130,7 @@ void parse_label(ClientOptionsParser::option_set_t& processed_options, ClientOpt

ClientOptionsParser::option_t label{std::string{"label"}, {}};

// This effectively always collects an argument (i.e. the label name)
parse_option(label, processed_options, args);

// Collect 1 positional argument (i.e. the label value)
Expand All @@ -129,6 +139,51 @@ void parse_label(ClientOptionsParser::option_set_t& processed_options, ClientOpt
processed_options.push_back(label);
}

void parse_meter(ClientOptionsParser::option_set_t& processed_options, ClientOptionsParser::arguments_set_t& args) {

// *** Important! ***
// This custom handler is needed to ensure that the "--meter" option
// special value parameters are handled correctly. For example,
// values starting with -, such as "-1".
//
// The custom handling will consider that 2 positional values (not
// to be confused with positional arguments) are provided with the
// --label option, as per one of the following forms:
// 1) --label arg1 arg2
// 2) --label=arg1 arg2

ClientOptionsParser::option_t meter{std::string{"meter"}, {}};

// This effectively always collects an argument (i.e. the meter name)
parse_option(meter, processed_options, args);

// Collect 1 positional argument (i.e. the meter value)
parse_positional_arguments(meter, processed_options, args, 1);

processed_options.push_back(meter);
}

void parse_abort(ClientOptionsParser::option_set_t& processed_options, ClientOptionsParser::arguments_set_t& args) {

// *** Important! ***
// This custom handler is needed to ensure that the "--abort" option
// special value parameters are handled correctly. For example,
// values starting with -, such as "--some reason--".
//
// The custom handling will consider that 2 positional values (not
// to be confused with positional arguments) are provided with the
// --label option, as per one of the following forms:
// 1) --label arg1 arg2
// 2) --label=arg1 arg2

ClientOptionsParser::option_t abort{std::string{"abort"}, {}};

// This effectively always collects an argument (i.e. the reason text)
parse_option(abort, processed_options, args);

processed_options.push_back(abort);
}

} // namespace

ClientOptionsParser::option_set_t ClientOptionsParser::operator()(ClientOptionsParser::arguments_set_t& args) {
Expand All @@ -140,6 +195,12 @@ ClientOptionsParser::option_set_t ClientOptionsParser::operator()(ClientOptionsP
else if (ecf::algorithm::starts_with(args[0], "--label")) {
parse_label(processed_options, args);
}
else if (ecf::algorithm::starts_with(args[0], "--meter")) {
parse_meter(processed_options, args);
}
else if (ecf::algorithm::starts_with(args[0], "--abort")) {
parse_abort(processed_options, args);
}
return processed_options;
}

Expand Down
4 changes: 4 additions & 0 deletions Base/src/ecflow/base/cts/task/MeterCmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ void MeterCmd::create(Cmd_ptr& cmd, boost::program_options::variables_map& vm, A
throw std::runtime_error(ss.str());
}

if (args[0].empty()) {
throw std::runtime_error("MeterCmd: First argument must be a non-empty string, i.e. --meter=name 100\n");
}

int value = 0;
try {
std::string strVal = args[1];
Expand Down
2 changes: 1 addition & 1 deletion Base/src/ecflow/base/cts/task/QueueCmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ const char* QueueCmd::desc() {
"definition\n"
" no_of_aborted: returns number of aborted steps as a string, i.e 10\n"
" reset: sets the index to the first queued/aborted step. Allows steps to be reprocessed for errors\n"
" arg2(string) = step: value returned from step=$(ecflow_client --queue=queue_name active)\n"
" arg3(string) = step: value returned from step=$(ecflow_client --queue=queue_name active)\n"
" This is only valid for complete and aborted steps\n"
" arg4(string) = path: (optional). The path where the queue is defined.\n"
" By default we search for the queue up the node tree.\n\n"
Expand Down
1 change: 1 addition & 0 deletions Base/src/ecflow/base/cts/user/BeginCmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ void BeginCmd::addOption(boost::program_options::options_description& desc) cons
}
void BeginCmd::create(Cmd_ptr& cmd, boost::program_options::variables_map& vm, AbstractClientEnv* ace) const {
std::string beginArg = vm[arg()].as<std::string>();
Str::removeQuotes(beginArg);

if (ace->debug()) {
cout << " BeginCmd::create arg = " << beginArg << "\n";
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ endif()
find_package( ecbuild 3.4 REQUIRED HINTS ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../ecbuild ) # Before project()

# this will generate variables, see ACore/ecflow_version.h.in
project( ecflow LANGUAGES CXX VERSION 5.12.2 )
project( ecflow LANGUAGES CXX VERSION 5.12.3 )

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)

Expand Down
Loading
Loading