Skip to content
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
7 changes: 6 additions & 1 deletion doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ Options

Wait for operation to finish (e.g. database update).

.. option:: -F, --force

Force certain operations (e.g. overwriting playlist while saving).

.. option:: --range=[START]:[END]

Operate on a range (e.g. when loading a playlist). START is the
Expand Down Expand Up @@ -250,7 +254,8 @@ Playlist Commands

:command:`rm <file>` - Deletes a specific playlist.

:command:`save <file>` - Saves playlist as <file>.
:command:`save [--force] <file>` - Saves playlist as <file>. With
:option:`--force`, overwrites the playlist if it already exists.

:command:`addplaylist <playlist> <file>` - Adds a song from the music database to the
playlist. The playlist will be created if it does not exist.
Expand Down
14 changes: 13 additions & 1 deletion src/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ SIMPLE_CMD(cmd_prev, mpd_run_previous, 1)
SIMPLE_CMD(cmd_stop, mpd_run_stop, 1)
SIMPLE_CMD(cmd_clearerror, mpd_run_clearerror, 1)

SIMPLE_ONEARG_CMD(cmd_save, mpd_run_save, 0)
SIMPLE_ONEARG_CMD(cmd_rm, mpd_run_rm, 0)

/**
Expand Down Expand Up @@ -1376,3 +1375,16 @@ cmd_partitiondelete(int argc, char **argv, struct mpd_connection *conn) {
}
return 0;
}

int
cmd_save(gcc_unused int argc, char **argv, struct mpd_connection *conn)
{
if (options.force) {
if (!mpd_send_save_queue(conn, charset_to_utf8(argv[0]), MPD_QUEUE_SAVE_MODE_REPLACE))
printErrorAndExit(conn);
} else {
if (!mpd_run_save(conn, charset_to_utf8(argv[0])))
printErrorAndExit(conn);
}
return 0;
}
5 changes: 5 additions & 0 deletions src/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ static const struct OptionDef option_table[] = {
{ 'w', "wait", NULL, "Wait for operation to finish (e.g. database update)" },
{ 'r', "range", "[<start>]:[<end>]", "Operate on a range (e.g. when loading a playlist)" },
{ 'a', "partition", "<name>", "Operate on partition <name> instead" },
{ 'F', "force", NULL, "Force some operations (like saving playlist)" },
{ OPTION_WITH_PRIO, "with-prio", NULL, "Show only songs that have a non-zero priority" },
};

Expand Down Expand Up @@ -164,6 +165,10 @@ handle_option(int c, const char *arg)
options.wait = true;
break;

case 'F':
options.force = true;
break;

case 'r':
ParseRange(&options.range, arg);
break;
Expand Down
1 change: 1 addition & 0 deletions src/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ struct Options {

int verbosity; // 0 for quiet, 1 for default, 2 for verbose
bool wait;
bool force;

bool custom_format;

Expand Down