protocol/ArgParser: add struct RangeArg

This commit is contained in:
Max Kellermann
2015-08-11 21:35:52 +02:00
parent 993df0fd28
commit cbdc3194cc
6 changed files with 60 additions and 51 deletions

View File

@@ -70,12 +70,10 @@ handle_save(Client &client, ConstBuffer<const char *> args)
CommandResult
handle_load(Client &client, ConstBuffer<const char *> args)
{
unsigned start_index, end_index;
if (args.size < 2) {
start_index = 0;
end_index = unsigned(-1);
} else if (!check_range(client, &start_index, &end_index, args[1]))
RangeArg range;
if (args.size < 2)
range.SetAll();
else if (!ParseCommandArg(client, range, args[1]))
return CommandResult::ERROR;
const ScopeBulkEdit bulk_edit(client.partition);
@@ -83,7 +81,7 @@ handle_load(Client &client, ConstBuffer<const char *> args)
Error error;
const SongLoader loader(client);
if (!playlist_open_into_queue(args.front(),
start_index, end_index,
range.start, range.end,
client.playlist,
client.player_control, loader, error))
return print_error(client, error);