Refactor CmdMove: Fail early if no id given

This commit is contained in:
Thomas Lauf 2018-01-05 14:27:25 +01:00
parent 35e5098b51
commit ecb8aa447c

View file

@ -42,19 +42,17 @@ int CmdMove (
std::vector<int> ids = cli.getIds(); std::vector<int> ids = cli.getIds();
if (ids.size() > 1) if (ids.size() > 1)
{
throw std::string("The 'move' command only supports a single ID."); throw std::string("The 'move' command only supports a single ID.");
}
int id;
if (ids.empty()) if (ids.empty())
{ {
id = 0; throw std::string ("ID must be specified. See 'timew help move'.");
}
else
{
id = ids[0];
} }
int id = ids[0];
std::string new_start; std::string new_start;
for (auto& arg : cli._args) for (auto& arg : cli._args)
{ {
@ -62,9 +60,6 @@ int CmdMove (
new_start = arg.attribute ("raw"); new_start = arg.attribute ("raw");
} }
if (! id)
throw std::string ("ID must be specified. See 'timew help move'.");
// Load the data. // Load the data.
// Note: There is no filter. // Note: There is no filter.
Interval filter; Interval filter;