Improve usability of clickhouse-client

This commit is contained in:
Alexey Milovidov 2021-04-05 05:49:13 +03:00
parent 0eba575fcf
commit 7a54558a29

View File

@ -527,7 +527,10 @@ private:
std::cerr << std::fixed << std::setprecision(3);
if (is_interactive)
{
clearTerminal();
showClientVersion();
}
is_default_format = !config().has("vertical") && !config().has("format");
if (config().has("vertical"))
@ -2467,6 +2470,17 @@ private:
std::cout << DBMS_NAME << " client version " << VERSION_STRING << VERSION_OFFICIAL << "." << std::endl;
}
static void clearTerminal()
{
/// Clear from cursor until end of screen.
/// It is needed if garbage is left in terminal.
/// Show cursor. It can be left hidden by invocation of previous programs.
/// A test for this feature: perl -e 'print "x"x100000'; echo -ne '\033[0;0H\033[?25l'; clickhouse-client
std::cout <<
"\033[0J"
"\033[?25h";
}
public:
void init(int argc, char ** argv)
{