Use terminal width for the formatted help text of the clickhouse-copier

Like other utils, clickhouse-client and so on (since copier uses Poco,
while other uses boost).
Otherwise clickhouse-copier --help is unreadable.
This commit is contained in:
Azat Khuzhin 2020-08-25 21:15:36 +03:00
parent 0b07121177
commit 0a34ae85a3

View File

@ -1,5 +1,7 @@
#include "ClusterCopierApp.h"
#include <Common/StatusFile.h>
#include <Common/TerminalSize.h>
#include <unistd.h>
namespace DB
@ -52,7 +54,13 @@ void ClusterCopierApp::initialize(Poco::Util::Application & self)
void ClusterCopierApp::handleHelp(const std::string &, const std::string &)
{
uint16_t terminal_width = 0;
if (isatty(STDIN_FILENO))
terminal_width = getTerminalWidth();
Poco::Util::HelpFormatter help_formatter(options());
if (terminal_width)
help_formatter.setWidth(terminal_width);
help_formatter.setCommand(commandName());
help_formatter.setHeader("Copies tables from one cluster to another");
help_formatter.setUsage("--config-file <config-file> --task-path <task-path>");