Skip to content

[cli] remove deprecated mem option #4116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 2 additions & 24 deletions src/client/cli/cmd/launch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,6 @@ mp::ParseCode cmd::Launch::parse_args(mp::ArgParser* parser)
default_memory_size)),
"memory",
QString::fromUtf8(default_memory_size)); // In MB's
QCommandLineOption memOptionDeprecated(
"mem",
QString::fromStdString("Deprecated memory allocation long option. See \"--memory\"."),
"memory",
QString::fromUtf8(default_memory_size));
memOptionDeprecated.setFlags(QCommandLineOption::HiddenFromHelp);

const auto valid_name_desc =
QString{"Valid names must consist of letters, numbers, or hyphens, must start with a "
Expand Down Expand Up @@ -265,7 +259,6 @@ mp::ParseCode cmd::Launch::parse_args(mp::ArgParser* parser)
parser->addOptions({cpusOption,
diskOption,
memOption,
memOptionDeprecated,
nameOption,
cloudInitOption,
networkOption,
Expand Down Expand Up @@ -348,24 +341,9 @@ mp::ParseCode cmd::Launch::parse_args(mp::ArgParser* parser)
request.set_num_cores(cpu_count);
}

if (parser->isSet(memOption) || parser->isSet(memOptionDeprecated))
if (parser->isSet(memOption))
{
if (parser->isSet(memOption) && parser->isSet(memOptionDeprecated))
{
cerr << "Error: invalid option(s) used for memory allocation. Please use \"--memory\" "
"to specify amount of "
"memory to allocate.\n";
return ParseCode::CommandLineError;
}

if (parser->isSet(memOptionDeprecated))
cerr << "Warning: the \"--mem\" long option is deprecated in favour of \"--memory\". "
"Please update any "
"scripts, etc.\n";

auto arg_mem_size = parser->isSet(memOption)
? parser->value(memOption).toStdString()
: parser->value(memOptionDeprecated).toStdString();
auto arg_mem_size = parser->value(memOption).toStdString();

mp::MemorySize{arg_mem_size}; // throw if bad

Expand Down
17 changes: 0 additions & 17 deletions tests/test_cli_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1188,23 +1188,6 @@ TEST_F(Client, launch_cmd_memory_option_fails_no_value)
EXPECT_THAT(send_command({"launch", "-m"}), Eq(mp::ReturnCode::CommandLineError));
}

TEST_F(Client, launch_cmd_memory_fails_duplicate_options)
{
EXPECT_THAT(send_command({"launch", "--memory", "2048M", "--mem", "2048M"}),
Eq(mp::ReturnCode::CommandLineError));
}

TEST_F(Client, launch_cmd_memory_deprecated_option_warning)
{
std::stringstream cerr_stream;

EXPECT_CALL(mock_daemon, launch(_, _));
EXPECT_THAT(send_command({"launch", "--mem", "2048M"}, trash_stream, cerr_stream),
Eq(mp::ReturnCode::Ok));
EXPECT_NE(std::string::npos, cerr_stream.str().find("Warning: the \"--mem\""))
<< "cout has: " << cerr_stream.str();
}

TEST_F(Client, launch_cmd_cpu_option_ok)
{
EXPECT_CALL(mock_daemon, launch(_, _));
Expand Down
Loading