Skip to content

Conversation

@oelmekki
Copy link

@oelmekki oelmekki commented Nov 8, 2025

Allow to replace an existing playlist with the mpc replace PLAYLIST command, calling mpd_send_save_queue with the MPD_QUEUE_SAVE_MODE_REPLACE flag.

Hi 👋

I was tired of having to do mpc rm PLAYLIST && mpc save PLAYLIST, so I implemented mpc replace PLAYLIST.

That… may be solving a first world problem. 😅

I don't know if you're interested in that or if you would consider it feature creep. I'm cool either way, I have the patch managed by Portage so I can patch my local copy of mpc, so no big deal if you think this patch doesn't belong in the main tree - just submitting it in case you think it does.

@MaxKellermann
Copy link
Member

I think replace is too generic; I believe it should rather be an option for the existing save command.

@oelmekki
Copy link
Author

Yes indeed, I thought the same thing. Actually, initially, I was going for overwriteplaylist, but I thought 1/ it was a mouthful, especially for people without completion, and 2/ it did not match the current semantic field for playlist basic operation (rm and save). I decided to go with replace to match rm and save, and the fact that the mpd flag is named MPD_QUEUE_SAVE_MODE_REPLACE, but let's face it: rm and save are already too generic, and the proper thing to do would be to rename them (if it were not for backward compatibility), not to follow their example and add more on top. addplaylist, delplaylist, etc are already showing the way.

I really like the idea of making it an option for save! That prevents commands creep while reflecting the fact that it's just a flag for save operation on the mpd side. I have to dig up more into the codebase to see how command options are implemented. Would save --replace work for you?

Allow to replace an existing playlist, calling mpd_send_save_queue with
the MPD_QUEUE_SAVE_MODE_REPLACE flag.
@oelmekki oelmekki changed the title ADD replace command ADD --force flag to cmd_save Nov 29, 2025
@oelmekki
Copy link
Author

Alright, I did change it to a flag.

So, looking at the implementation of options and seeing they are not actually bound to a command but always global, I decided to go with the --force option instead, so that the command is now mpc save --force <playlist>. I chose this more general name (which is a good thing this time) over --replace, so that other commands may leverage it in the future without having to implement similar sounding options all on the global list of options (replace, overwrite, do-it-for-real, etc).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants