--version (fix #939)

This commit is contained in:
Adrian Sampson 2014-09-10 19:35:34 -07:00
parent 6dd6d4770e
commit 832f34c46c
2 changed files with 10 additions and 2 deletions

View file

@ -689,6 +689,8 @@ class SubcommandsOptionParser(optparse.OptionParser):
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)

View file

@ -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