Skip to content

Commit

Permalink
fix session set command at empty string handling
Browse files Browse the repository at this point in the history
  • Loading branch information
t-horikawa committed Sep 18, 2024
1 parent ad48f01 commit 116dfb1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/tateyama/session/session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ tgctl::return_code session_shutdown(std::string_view session_ref) {
return rtnv;
}

tgctl::return_code session_swtch(std::string_view session_ref, std::string_view set_key, std::string_view set_value) {
tgctl::return_code session_swtch(std::string_view session_ref, std::string_view set_key, std::string_view set_value, bool set) {
std::unique_ptr<monitor::monitor> monitor_output{};

if (!FLAGS_monitor.empty()) {
Expand All @@ -324,7 +324,7 @@ tgctl::return_code session_swtch(std::string_view session_ref, std::string_view
auto* command = request.mutable_session_set_variable();
command->set_session_specifier(std::string(session_ref));
command->set_name(std::string(set_key));
if (!set_value.empty()) {
if (set) {
command->set_value(std::string(set_value));
}
auto response_opt = transport->send<::tateyama::proto::session::response::SessionSetVariable>(request);
Expand Down
2 changes: 1 addition & 1 deletion src/tateyama/session/session.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ namespace tateyama::session {
tgctl::return_code session_list();
tgctl::return_code session_show(std::string_view session_ref);
tgctl::return_code session_shutdown(std::string_view session_ref);
tgctl::return_code session_swtch(std::string_view session_ref, std::string_view set_key, std::string_view set_value = "");
tgctl::return_code session_swtch(std::string_view session_ref, std::string_view set_key, std::string_view set_value = "", bool set = false);

} // tateyama::session
2 changes: 1 addition & 1 deletion src/tateyama/tgctl/tgctl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ int tgctl_main(const std::vector<std::string>& args) { //NOLINT(readability-func
if (args.size() < 6) {
return tateyama::session::session_swtch(args.at(3), args.at(4));
}
return tateyama::session::session_swtch(args.at(3), args.at(4), args.at(5));
return tateyama::session::session_swtch(args.at(3), args.at(4), args.at(5), true);
}
std::cerr << "unknown session sub command '" << args.at(2) << "'" << std::endl;
return tateyama::tgctl::return_code::err;
Expand Down

1 comment on commit 116dfb1

@t-horikawa
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.