MCPcopy Create free account
hub / github.com/Tencent/TAD_Sim / _process_env

Method _process_env

simcore/framework/src/cli/cli.hpp:6456–6484  ·  view source on GitHub ↗

Get envname options if not yet passed. Runs on *all* subcommands.

Source from the content-addressed store, hash-verified

6454
6455 /// Get envname options if not yet passed. Runs on *all* subcommands.
6456 void _process_env() {
6457 for (const Option_p &opt : options_) {
6458 if (opt->count() == 0 && !opt->envname_.empty()) {
6459 char *buffer = nullptr;
6460 std::string ename_string;
6461
6462#ifdef _MSC_VER
6463 // Windows version
6464 std::size_t sz = 0;
6465 if (_dupenv_s(&buffer, &sz, opt->envname_.c_str()) == 0 && buffer != nullptr) {
6466 ename_string = std::string(buffer);
6467 free(buffer);
6468 }
6469#else
6470 // This also works on Windows, but gives a warning
6471 buffer = std::getenv(opt->envname_.c_str());
6472 if (buffer != nullptr) ename_string = std::string(buffer);
6473#endif
6474
6475 if (!ename_string.empty()) {
6476 opt->add_result(ename_string);
6477 }
6478 }
6479 }
6480
6481 for (App_p &sub : subcommands_) {
6482 if (sub->get_name().empty() || !sub->parse_complete_callback_) sub->_process_env();
6483 }
6484 }
6485
6486 /// Process callbacks. Runs on *all* subcommands.
6487 void _process_callbacks() {

Callers

nothing calls this directly

Calls 4

add_resultMethod · 0.80
countMethod · 0.45
emptyMethod · 0.45
get_nameMethod · 0.45

Tested by

no test coverage detected