Listall
This commit is contained in:
parent
13f72c15db
commit
38995d2456
1 changed files with 17 additions and 2 deletions
|
|
@ -62,7 +62,8 @@ action_map = {
|
||||||
"removeall": 2,
|
"removeall": 2,
|
||||||
"show": 3,
|
"show": 3,
|
||||||
"transfer": 4,
|
"transfer": 4,
|
||||||
"edit": 5
|
"edit": 5,
|
||||||
|
"listall": 6,
|
||||||
}
|
}
|
||||||
|
|
||||||
def modify_labels(lib, opts, args):
|
def modify_labels(lib, opts, args):
|
||||||
|
|
@ -86,6 +87,10 @@ def modify_labels(lib, opts, args):
|
||||||
edit_labels(lib, opts, args[1:])
|
edit_labels(lib, opts, args[1:])
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if actnum == 6: # listall
|
||||||
|
listall_labels(lib, opts, args[1:])
|
||||||
|
return
|
||||||
|
|
||||||
if actnum >= 2:
|
if actnum >= 2:
|
||||||
label = None
|
label = None
|
||||||
query = args[1:]
|
query = args[1:]
|
||||||
|
|
@ -104,6 +109,15 @@ def modify_labels(lib, opts, args):
|
||||||
else:
|
else:
|
||||||
do_modify_labels(lib, items, label, actnum)
|
do_modify_labels(lib, items, label, actnum)
|
||||||
|
|
||||||
|
def listall_labels(lib, opts, args):
|
||||||
|
"""Print every distinct label key used across all items."""
|
||||||
|
all_labels = set()
|
||||||
|
for item in lib.items():
|
||||||
|
if LABELS_FIELD_NAME in item and item[LABELS_FIELD_NAME]:
|
||||||
|
all_labels.update(item[LABELS_FIELD_NAME].keys())
|
||||||
|
for label in sorted(all_labels):
|
||||||
|
print_(label)
|
||||||
|
|
||||||
def transfer_labels(lib, opts, args):
|
def transfer_labels(lib, opts, args):
|
||||||
source_query = args[0]
|
source_query = args[0]
|
||||||
dest_query = args[1]
|
dest_query = args[1]
|
||||||
|
|
@ -343,7 +357,8 @@ Actions:
|
||||||
show [query] Display labels on items
|
show [query] Display labels on items
|
||||||
transfer <src-query> <dst-query>
|
transfer <src-query> <dst-query>
|
||||||
Copy labels from one item to another
|
Copy labels from one item to another
|
||||||
edit [query] Open items' labels in a text editor"""
|
edit [query] Open items' labels in a text editor
|
||||||
|
listall List all label keys used in the library"""
|
||||||
labels_command.func = modify_labels
|
labels_command.func = modify_labels
|
||||||
|
|
||||||
class HasLabelQuery(FieldQuery):
|
class HasLabelQuery(FieldQuery):
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue