@@ -55,21 +55,29 @@ cpp::result<void, std::string> EngineUseCmd::Exec(const std::string& host,
5555 return cpp::fail (" Invalid variant selection" );
5656 }
5757
58- auto selected_version = cli_selection_utils::PrintSelection (
59- variant_map[selected_variant.value ()]);
60- if (!selected_variant.has_value ()) {
58+ std::optional<std::string> selected_version = std::nullopt ;
59+ if (variant_map[selected_variant.value ()].size () == 1 ) {
60+ selected_version = variant_map[selected_variant.value ()][0 ];
61+ } else {
62+ selected_version = cli_selection_utils::PrintSelection (
63+ variant_map[selected_variant.value ()]);
64+ }
65+ if (!selected_version.has_value ()) {
6166 CTL_ERR (" Invalid version selection" );
6267 return cpp::fail (" Invalid version selection" );
6368 }
6469
70+ Json::Value body;
71+ body[" variant" ] = selected_variant.value ();
72+ body[" version" ] = selected_version.value ();
6573 auto set_default_engine_variant = url_parser::Url{
6674 .protocol = " http" ,
6775 .host = host + " :" + std::to_string (port),
6876 .pathParams = {" v1" , " engines" , engine, " default" },
6977 };
7078
71- auto response =
72- curl_utils::SimplePostJson ( set_default_engine_variant.ToFullPath ());
79+ auto response = curl_utils::SimplePostJson (
80+ set_default_engine_variant.ToFullPath (), body. toStyledString ());
7381 if (response.has_error ()) {
7482 CTL_ERR (response.error ());
7583 return cpp::fail (" Failed to set default engine variant" );
0 commit comments