Merge pull request #22634 from ClickHouse/client-improve-usability

Improve usability of clickhouse-client
This commit is contained in:
alexey-milovidov 2021-04-05 09:00:29 +03:00 committed by GitHub
commit 92f57fd669
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -527,7 +527,10 @@ private:
std::cerr << std::fixed << std::setprecision(3); std::cerr << std::fixed << std::setprecision(3);
if (is_interactive) if (is_interactive)
{
clearTerminal();
showClientVersion(); showClientVersion();
}
is_default_format = !config().has("vertical") && !config().has("format"); is_default_format = !config().has("vertical") && !config().has("format");
if (config().has("vertical")) if (config().has("vertical"))
@ -2467,6 +2470,17 @@ private:
std::cout << DBMS_NAME << " client version " << VERSION_STRING << VERSION_OFFICIAL << "." << std::endl; 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: public:
void init(int argc, char ** argv) void init(int argc, char ** argv)
{ {