Skip to content

Commit

Permalink
[cli] edit user strings and optimize loops
Browse files Browse the repository at this point in the history
  • Loading branch information
sharder996 committed Jun 13, 2023
1 parent 98074ce commit 2803ec5
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/client/cli/cmd/delete.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,10 @@ QString cmd::Delete::short_help() const

QString cmd::Delete::description() const
{
return QStringLiteral("Delete instances and snapshots, to be purged with the \"purge\" command,\n"
"or recovered with the \"recover\" command (instances only).");
return QStringLiteral(
"Delete instances and snapshots. Instances can be purged immediately or later on,"
"with the \"purge\" command. Until they are purged, instances can be recovered"
"with the \"recover\" command. Snapshots cannot be recovered after deletion and must be purged at once.");
}

mp::ParseCode cmd::Delete::parse_args(mp::ArgParser* parser)
Expand All @@ -82,7 +84,7 @@ mp::ParseCode cmd::Delete::parse_args(mp::ArgParser* parser)
"<instance>[.snapshot] [<instance>[.snapshot] ...]");

QCommandLineOption all_option(all_option_name, "Delete all instances and snapshots");
QCommandLineOption purge_option({"p", "purge"}, "Purge deleted instances and snapshots immediately");
QCommandLineOption purge_option({"p", "purge"}, "Purge specified instances and snapshots immediately");
parser->addOptions({all_option, purge_option});

auto status = parser->commandParse(this);
Expand All @@ -93,21 +95,18 @@ mp::ParseCode cmd::Delete::parse_args(mp::ArgParser* parser)
if (parse_code != ParseCode::Ok)
return parse_code;

for (const auto& arg : parser->positionalArguments())
request.set_purge(parser->isSet(purge_option));
for (const auto& item : add_instance_and_snapshot_names(parser))
{
if (arg.indexOf('.') >= 0 && !parser->isSet("purge"))
if (item.has_snapshot_name() && !request.purge())
{
cerr << "Snapshots can only be purged (after deletion, they cannot be recovered). Please use the `--purge` "
"flag if that is what you want.\n";
return mp::ParseCode::CommandLineError;
}
}

for (const auto& item : add_instance_and_snapshot_names(parser))
request.add_instances_snapshots()->CopyFrom(item);

if (parser->isSet(purge_option))
request.set_purge(true);
}

return status;
}

0 comments on commit 2803ec5

Please sign in to comment.