diff --git a/DOCS/interface-changes/list-option.txt b/DOCS/interface-changes/list-option.txt index 98785ad4e2..f0697acd7c 100644 --- a/DOCS/interface-changes/list-option.txt +++ b/DOCS/interface-changes/list-option.txt @@ -1,2 +1,3 @@ undeprecate list option suffixes that work with multiple items add `-del` to string list and keyvalue list options +add `-clr` to keyvalue list options diff --git a/DOCS/man/mpv.rst b/DOCS/man/mpv.rst index 4f54908247..84af8dd43e 100644 --- a/DOCS/man/mpv.rst +++ b/DOCS/man/mpv.rst @@ -676,6 +676,7 @@ Suffix Meaning -set Set a list of items (using ``,`` as separator) -append Append a single item (escapes for the key, no escapes for the value) -add Append 1 or more items (same syntax as -set) +-clr Clear the option (remove all items) -del Delete 1 or more keys if present (same syntax as -set) -remove Delete item by key if present (does not interpret escapes) ============= =============================================== diff --git a/options/m_option.c b/options/m_option.c index c72257e5be..1c2131e8fc 100644 --- a/options/m_option.c +++ b/options/m_option.c @@ -1718,6 +1718,10 @@ static int parse_keyvalue_list(struct mp_log *log, const m_option_t *opt, append = true; } else if (bstr_endswith0(name, "-append")) { append = full_value = true; + } else if (bstr_endswith0(name, "-clr")) { + if (dst) + free_str_list(dst); + return 0; } else if (op == OP_DEL || op == OP_REMOVE) { int n = 0; char **res = separate_input_param(opt, param, &n, op); @@ -1861,6 +1865,7 @@ const m_option_type_t m_option_type_keyvalue_list = { .actions = (const struct m_option_action[]){ {"add"}, {"append"}, + {"clr", M_OPT_TYPE_OPTIONAL_PARAM}, {"del"}, {"set"}, {"remove"},