mirror of
https://github.com/beetbox/beets.git
synced 2025-12-06 08:39:17 +01:00
expanded usefulness of "bts set" command
--HG-- extra : convert_revision : svn%3A41726ec3-264d-0410-9c23-a9f1637257cc/trunk%40213
This commit is contained in:
parent
8a0519c914
commit
9e6953246d
2 changed files with 17 additions and 5 deletions
|
|
@ -606,8 +606,13 @@ class Library(object):
|
|||
self.library = library
|
||||
|
||||
def _validate_key(self, key):
|
||||
if key not in library_options:
|
||||
if key not in self:
|
||||
raise ValueError(key + " is not a valid option name")
|
||||
|
||||
def __iter__(self):
|
||||
return iter(library_options)
|
||||
def __contains__(self, key):
|
||||
return key in library_options
|
||||
|
||||
def __getitem__(self, key):
|
||||
"""Return the current value of option "key"."""
|
||||
|
|
|
|||
15
bts
15
bts
|
|
@ -56,9 +56,16 @@ def imp(lib, config, paths):
|
|||
lib.save()
|
||||
|
||||
def option(lib, config, options):
|
||||
(key, value) = options
|
||||
lib.options[key] = value
|
||||
lib.save()
|
||||
if len(options) == 1: # Get.
|
||||
(key,) = options
|
||||
_print(lib.options[key])
|
||||
elif len(options) == 2: # Set.
|
||||
(key, value) = options
|
||||
lib.options[key] = value
|
||||
lib.save()
|
||||
elif len(options) == 0: # List.
|
||||
for key in lib.options:
|
||||
print key
|
||||
|
||||
def remove(lib, config, criteria):
|
||||
q = ' '.join(criteria)
|
||||
|
|
@ -105,7 +112,7 @@ def bpd(lib, config, opts):
|
|||
if __name__ == "__main__":
|
||||
# parse options
|
||||
usage = """usage: %prog [options] command
|
||||
command is one of: add, remove, update, write, list, bpd, tagalbum, help"""
|
||||
command is one of: add, remove, update, write, list, set, bpd, tagalbum, help"""
|
||||
op = OptionParser(usage=usage)
|
||||
op.add_option('-l', '--library', dest='libpath', metavar='PATH',
|
||||
default=None,
|
||||
|
|
|
|||
Loading…
Reference in a new issue