Compare commits
2 commits
5c564d21b0
...
f8e1beeb3d
| Author | SHA1 | Date | |
|---|---|---|---|
| f8e1beeb3d | |||
| 8656a828d2 |
1 changed files with 20 additions and 4 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
from beets import ui
|
from beets import ui
|
||||||
from beets.ui import Subcommand, print_
|
from beets.ui import Subcommand, print_
|
||||||
from beets.ui.commands import print_and_modify
|
from beets.ui.commands.modify import print_and_modify
|
||||||
from beets.dbcore import FieldQuery
|
from beets.dbcore import FieldQuery
|
||||||
from beets.dbcore.query import SlowFieldSort
|
from beets.dbcore.query import SlowFieldSort
|
||||||
|
|
||||||
|
|
@ -65,11 +65,14 @@ action_map = {
|
||||||
}
|
}
|
||||||
|
|
||||||
def modify_labels(lib, opts, args):
|
def modify_labels(lib, opts, args):
|
||||||
|
if not args:
|
||||||
|
labels_command.parser.print_usage()
|
||||||
|
return
|
||||||
|
|
||||||
action = args[0]
|
action = args[0]
|
||||||
|
|
||||||
if action not in action_map:
|
if action not in action_map:
|
||||||
print_("%s is not a valid action. " % action)
|
print_("%s is not a valid action. Run 'beet labels --help' for usage." % action)
|
||||||
print_("Valid actions are: add, remove, removeall, show, transfer, edit")
|
|
||||||
return
|
return
|
||||||
|
|
||||||
actnum = action_map[action]
|
actnum = action_map[action]
|
||||||
|
|
@ -297,7 +300,20 @@ def edit_labels(lib, opts, args):
|
||||||
|
|
||||||
print_(f"Updated {len(changes)} item(s).")
|
print_(f"Updated {len(changes)} item(s).")
|
||||||
|
|
||||||
labels_command = Subcommand('labels', help='Add or remove labels')
|
labels_command = Subcommand(
|
||||||
|
'labels',
|
||||||
|
help='Add, remove, or inspect labels on library items'
|
||||||
|
)
|
||||||
|
labels_command.parser.usage = """%prog labels <action> [args] [query]
|
||||||
|
|
||||||
|
Actions:
|
||||||
|
add <label>[:<cost>] [query] Add a label (optionally with a cost value)
|
||||||
|
remove <label> [query] Remove a label from items
|
||||||
|
removeall [query] Remove all labels from items
|
||||||
|
show [query] Display labels on items
|
||||||
|
transfer <src-query> <dst-query>
|
||||||
|
Copy labels from one item to another
|
||||||
|
edit [query] Open items' labels in a text editor"""
|
||||||
labels_command.func = modify_labels
|
labels_command.func = modify_labels
|
||||||
|
|
||||||
class HasLabelQuery(FieldQuery):
|
class HasLabelQuery(FieldQuery):
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue