diff --git a/micromamba/src/run.cpp b/micromamba/src/run.cpp index a5d2956a22..808ec1358a 100644 --- a/micromamba/src/run.cpp +++ b/micromamba/src/run.cpp @@ -12,30 +12,43 @@ set_run_command(CLI::App* subcom) { init_prefix_options(subcom); - static std::vector command; + static bool live_stream = true; + subcom->add_flag("--live-stream", live_stream, "Display output live"); - subcom->add_option( - "executable_call", - command, - "Executable name, with additional arguments to be passed to the executable on invocation"); + static std::vector command; + subcom->prefix_command(); - subcom->callback([]() { + subcom->callback([subcom]() { auto& config = Configuration::instance(); config.load(); + std::vector command = subcom->remaining(); + auto [wrapped_command, script_file] = prepare_wrapped_call(Context::instance().target_prefix, command); LOG_DEBUG << "Running wrapped script " << join(" ", command); - std::string out, err; - auto [_, ec] = reproc::run(wrapped_command, - reproc::options(), - reproc::sink::string(out), - reproc::sink::string(err)); - if (ec) + std::string out, err; + if (!live_stream) + { + auto [_, ec] = reproc::run(wrapped_command, + reproc::options(), + reproc::sink::string(out), + reproc::sink::string(err)); + if (ec) + { + std::cerr << ec.message() << std::endl; + } + } + else { - std::cerr << ec.message() << std::endl; + auto [_, ec] = reproc::run(wrapped_command, reproc::options()); + + if (ec) + { + std::cerr << ec.message() << std::endl; + } } }); }