Files
tai/taicpp/tests/mplex_cli_main.cpp
T

31 lines
1003 B
C++

// Test artifact: runs the C++ mplex client/server as a standalone binary, mirroring what
// tai.py main does for `--mplex [COMMAND...]` and `--plexer-wrap`. Not part of the detz build.
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include "mplex_client.h"
int main(int argc, char** argv) {
using namespace detz::mplex;
std::string home;
const char* env_home = std::getenv("TAI_HOME");
if (env_home && *env_home) {
home = env_home;
} else {
const char* user_home = std::getenv("HOME");
home = std::string(user_home ? user_home : "") + "/.tai";
}
if (argc >= 2 && std::strcmp(argv[1], "--mplex") == 0) {
std::vector<std::string> words(argv + 2, argv + argc);
return MplexCli::main(home, words);
}
if (argc >= 2 && std::strcmp(argv[1], "--plexer-wrap") == 0) {
NativePlexerBackend backend(home, "default");
return backend.run();
}
std::fputs("usage: mplex_cli --mplex [COMMAND...] | --plexer-wrap\n", stderr);
return 2;
}