diff --git a/beets/ui/__init__.py b/beets/ui/__init__.py index 2e61611d9f..82205e0e07 100644 --- a/beets/ui/__init__.py +++ b/beets/ui/__init__.py @@ -689,6 +689,8 @@ def __init__(self, *args, **kwargs): help='path to configuration file') self.add_option('-h', '--help', dest='help', action='store_true', help='how this help message and exit') + self.add_option('--version', dest='version', action='store_true', + help=optparse.SUPPRESS_HELP) # Our root parser needs to stop on the first unrecognized argument. self.disable_interspersed_args() @@ -948,9 +950,14 @@ def _raw_main(args, lib=None): subcommands, plugins, lib = _setup(options, lib) parser.add_subcommand(*subcommands) - subcommand, suboptions, subargs = parser.parse_subcommand(subargs) - subcommand.func(lib, suboptions, subargs) + if options.version: + from beets.ui import commands + commands.version_cmd.func(lib, None, None) + else: + subcommand, suboptions, subargs = parser.parse_subcommand(subargs) + subcommand.func(lib, suboptions, subargs) + plugins.send('cli_exit', lib=lib) diff --git a/docs/changelog.rst b/docs/changelog.rst index db19d72062..04ecfea24d 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -42,6 +42,7 @@ Fixes: * :doc:`/plugins/play`: Add a ``relative_to`` config option. Thanks to BrainDamage. * Fix a crash when a MusicBrainz release has zero tracks. +* The ``--version`` flag now works as an alias for the ``version`` command. .. _discogs_client: https://github.com/discogs/discogs_client