Skip to content

Commit 8a58d94

Browse files
authored
fix: database in ns_client (#2139)
1 parent 0f64e4a commit 8a58d94

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/cmd/openmldb.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3682,7 +3682,7 @@ void StartClient() {
36823682
void StartNsClient() {
36833683
std::string endpoint;
36843684
std::string real_endpoint;
3685-
if (FLAGS_interactive) {
3685+
if (FLAGS_cmd.empty()) {
36863686
std::cout << "Welcome to openmldb with version " << OPENMLDB_VERSION << std::endl;
36873687
}
36883688
std::shared_ptr<::openmldb::zk::ZkClient> zk_client;
@@ -3746,8 +3746,12 @@ void StartNsClient() {
37463746
std::string buffer;
37473747
display_prefix = endpoint + " " + client.GetDb() + "> ";
37483748
multi_line_perfix = std::string(display_prefix.length() - 3, ' ') + "-> ";
3749-
if (!FLAGS_interactive) {
3749+
if (!FLAGS_cmd.empty()) {
37503750
buffer = FLAGS_cmd;
3751+
if (!FLAGS_database.empty()) {
3752+
std::string error;
3753+
client.Use(FLAGS_database, error);
3754+
}
37513755
} else {
37523756
char* line = ::openmldb::base::linenoise(multi_line ? multi_line_perfix.c_str() : display_prefix.c_str());
37533757
if (line == NULL) {

0 commit comments

Comments
 (0)