History

m_option: add -clr to keyvalue list options

Seems to have been omitted by mistake and nobody ever noticed.

Dudemanguy committed 1 year ago

Commit 4c3eb161 parent d2c409c3 files · +7 −0Browse files

Unified · Split

3 files
  1. DOCS/interface-changes/list-option.txt +1 −0
  2. DOCS/man/mpv.rst +1 −0
  3. options/m_option.c +5 −0
DOCS/interface-changes/list-option.txt+1−0
@@ -1,2 +1,3 @@
11 undeprecate list option suffixes that work with multiple items
22 add `-del` to string list and keyvalue list options
3+add `-clr` to keyvalue list options
DOCS/man/mpv.rst+1−0
@@ -676,6 +676,7 @@ Suffix Meaning · 675 unmodified lines
676676 -set Set a list of items (using ``,`` as separator)
677677 -append Append a single item (escapes for the key, no escapes for the value)
678678 -add Append 1 or more items (same syntax as -set)
679+-clr Clear the option (remove all items)
679680 -del Delete 1 or more keys if present (same syntax as -set)
680681 -remove Delete item by key if present (does not interpret escapes)
681682 ============= ===============================================
options/m_option.c+5−0
@@ -1718,6 +1718,10 @@ static int parse_keyvalue_list(struct mp_log *log, const m_option_t *opt, · 1717 unmodified lines
17181718 append = true;
17191719 } else if (bstr_endswith0(name, "-append")) {
17201720 append = full_value = true;
1721+ } else if (bstr_endswith0(name, "-clr")) {
1722+ if (dst)
1723+ free_str_list(dst);
1724+ return 0;
17211725 } else if (op == OP_DEL || op == OP_REMOVE) {
17221726 int n = 0;
17231727 char **res = separate_input_param(opt, param, &n, op);
@@ -1861,6 +1865,7 @@ const m_option_type_t m_option_type_keyvalue_list = { · 137 unmodified lines
18611865 .actions = (const struct m_option_action[]){
18621866 {"add"},
18631867 {"append"},
1868+ {"clr", M_OPT_TYPE_OPTIONAL_PARAM},
18641869 {"del"},
18651870 {"set"},
18661871 {"remove"},

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t