rewire/cli/cli.cpp

27 lines
588 B
C++

#include "cli.hpp"
#include <cstring>
#include <cstdlib>
LAUNCH_MODE launch_mode(const char* str) {
if (std::strcmp(str, "help") == 0)
return LAUNCH_MODE::HELP;
else if (std::strcmp(str, "install") == 0)
return LAUNCH_MODE::INSTALL;
else if (std::strcmp(str, "uninstall") == 0)
return LAUNCH_MODE::UNINSTALL;
else if (std::strcmp(str, "list") == 0)
return LAUNCH_MODE::LIST;
else
return LAUNCH_MODE::RUN;
}
bool home_directory(std::string& str) {
const char* hd_cstr = std::getenv("HOME");
if (!hd_cstr)
return false;
str = std::string{ hd_cstr };
return true;
}