diff --git a/beets/util/confit.py b/beets/util/confit.py index 9f3cd5cc7..b26fae4b1 100644 --- a/beets/util/confit.py +++ b/beets/util/confit.py @@ -151,6 +151,16 @@ class ConfigView(object): """ self.overlay[key] = value + def add_args(self, namespace): + """Add parsed command-line arguments, generated by a library + like argparse or optparse, to this view's overlay. + """ + args = {} + for key, value in namespace.__dict__.items(): + if value is not None: # Avoid unset options. + args[key] = value + self.overlay.update(args) + # Magical conversions. These special methods make it possible to use # View objects somewhat transparently in certain circumstances. For # example, rather than using ``view.get(bool)``, it's possible to @@ -482,17 +492,6 @@ class Configuration(RootView): for filename in self._filenames(): self.sources.append(load_yaml(filename)) - def add_args(self, namespace): - """Add parsed command-line arguments, generated by a library - like argparse or optparse, as an overlay to the configuration - sources. - """ - arg_source = {} - for key, value in namespace.__dict__.items(): - if value is not None: # Avoid unset options. - arg_source[key] = value - self.sources.insert(0, arg_source) - def config_dir(self): """Get the path to the directory containing the highest-priority user configuration. If no user configuration is present, create a