Skip to content

Commit

Permalink
Add YQL syntax highlighting to YDB CLI (#7448)
Browse files Browse the repository at this point in the history
Signed-off-by: vityaman <vityaman.dev@yandex.ru>
  • Loading branch information
vityaman authored Sep 5, 2024
1 parent f2c3c58 commit 02d3e0b
Show file tree
Hide file tree
Showing 7 changed files with 824 additions and 3 deletions.
6 changes: 6 additions & 0 deletions ydb/public/lib/ydb_cli/commands/interactive/line_reader.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "line_reader.h"
#include "yql_highlight.h"

#include <util/generic/string.h>
#include <util/system/file.h>
Expand Down Expand Up @@ -92,7 +93,12 @@ TLineReader::TLineReader(std::string prompt, std::string historyFilePath, Sugges
return completions;
};

auto highlighter_callback = [](const auto& text, auto& colors) {
return YQLHighlight(YQLHighlight::ColorSchema::Monaco()).Apply(text, colors);
};

Rx.set_completion_callback(completion_callback);
Rx.set_highlighter_callback(highlighter_callback);
Rx.enable_bracketed_paste();
Rx.set_unique_history(true);
Rx.set_complete_on_empty(false);
Expand Down
7 changes: 7 additions & 0 deletions ydb/public/lib/ydb_cli/commands/interactive/ut/ya.make
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
UNITTEST_FOR(ydb/public/lib/ydb_cli/commands/interactive)

SRCS(
yql_highlight_ut.cpp
)

END()
20 changes: 20 additions & 0 deletions ydb/public/lib/ydb_cli/commands/interactive/ya.make
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
LIBRARY()

SRCS(
interactive_cli.cpp
line_reader.cpp
yql_highlight.cpp
)

PEERDIR(
contrib/restricted/patched/replxx
contrib/libs/antlr4_cpp_runtime
ydb/library/yql/parser/proto_ast/gen/v1_antlr4
ydb/public/lib/ydb_cli/common
)

END()

RECURSE_FOR_TESTS(
ut
)
Loading

0 comments on commit 02d3e0b

Please sign in to comment.