diff --git a/beets/library.py b/beets/library.py index 0a7cab299..2cdd6c9a6 100644 --- a/beets/library.py +++ b/beets/library.py @@ -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".""" diff --git a/bts b/bts index 63a7b67f3..d893805d0 100755 --- a/bts +++ b/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,