mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-04 13:32:13 +00:00
clickhouse-format support option --query
This commit is contained in:
parent
56c0767063
commit
08983e432b
@ -44,6 +44,7 @@ int mainEntryClickHouseFormat(int argc, char ** argv)
|
|||||||
|
|
||||||
boost::program_options::options_description desc = createOptionsDescription("Allowed options", getTerminalWidth());
|
boost::program_options::options_description desc = createOptionsDescription("Allowed options", getTerminalWidth());
|
||||||
desc.add_options()
|
desc.add_options()
|
||||||
|
("query", po::value<std::string>(), "query to format")
|
||||||
("help,h", "produce help message")
|
("help,h", "produce help message")
|
||||||
("hilite", "add syntax highlight with ANSI terminal escape sequences")
|
("hilite", "add syntax highlight with ANSI terminal escape sequences")
|
||||||
("oneline", "format in single line")
|
("oneline", "format in single line")
|
||||||
@ -86,8 +87,16 @@ int mainEntryClickHouseFormat(int argc, char ** argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
String query;
|
String query;
|
||||||
ReadBufferFromFileDescriptor in(STDIN_FILENO);
|
|
||||||
readStringUntilEOF(query, in);
|
if (options.count("query"))
|
||||||
|
{
|
||||||
|
query = options["query"].as<std::string>();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ReadBufferFromFileDescriptor in(STDIN_FILENO);
|
||||||
|
readStringUntilEOF(query, in);
|
||||||
|
}
|
||||||
|
|
||||||
if (obfuscate)
|
if (obfuscate)
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
SELECT 1
|
7
tests/queries/0_stateless/02031_format_query_option.sh
Executable file
7
tests/queries/0_stateless/02031_format_query_option.sh
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||||
|
# shellcheck source=../shell_config.sh
|
||||||
|
. "$CURDIR"/../shell_config.sh
|
||||||
|
|
||||||
|
${CLICKHOUSE_FORMAT} --query "SELECT 1"
|
Loading…
Reference in New Issue
Block a user