Commit 8ad0767a authored by aligungr's avatar aligungr

gNB CLI improvements

parent b7a56d6d
......@@ -214,9 +214,15 @@ static bool HandleMessage(const app::CliMessage &msg, bool isOneShot)
std::cout << "\x1b[1m";
std::cout << std::string(92, '-') << std::endl;
std::string line{};
bool isEof{};
std::vector<std::string> tokens{};
if (!opt::ReadLine(std::cin, std::cout, line, tokens))
exit(0);
if (!opt::ReadLine(std::cin, std::cout, line, tokens, isEof))
{
if (isEof)
exit(0);
else
std::cout << "ERROR: Invalid command" << std::endl;
}
std::cout << "\x1b[0m";
if (line.empty())
continue;
......
......@@ -361,17 +361,22 @@ opt::ExpansionResult opt::PerformExpansion(const std::string &command, std::vect
return ExpansionResult::UNSPECIFIED_ERROR;
}
bool opt::ReadLine(std::istream &istream, std::ostream &ostream, std::string &line, std::vector<std::string> &tokens)
bool opt::ReadLine(std::istream &istream, std::ostream &ostream, std::string &line, std::vector<std::string> &tokens,
bool &isEof)
{
ostream << "$ ";
std::string input{};
isEof = false;
while (true)
{
std::string ln{};
std::getline(istream, ln);
if (!istream)
{
isEof = true;
return false;
}
input += ln;
std::vector<std::string> vec{};
......
......@@ -127,6 +127,7 @@ enum class ExpansionResult
ExpansionResult PerformExpansion(const std::string &command, std::vector<std::string> &argv);
bool ReadLine(std::istream &istream, std::ostream &ostream, std::string &line, std::vector<std::string> &tokens);
bool ReadLine(std::istream &istream, std::ostream &ostream, std::string &line, std::vector<std::string> &tokens,
bool &isEof);
} // namespace opt
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment