diff --git a/beetsplug/play.py b/beetsplug/play.py index 156bffba3..c7d1403e0 100644 --- a/beetsplug/play.py +++ b/beetsplug/play.py @@ -35,7 +35,6 @@ class PlayPlugin(BeetsPlugin): 'command': None, 'use_folders': False, 'relative_to': None, - 'args': None, }) def commands(self): @@ -47,7 +46,7 @@ class PlayPlugin(BeetsPlugin): play_command.parser.add_option( '-A', '--args', action='store', - help='Insert additional arguments into command string' + help='add additional arguments to the command', ) play_command.func = self.play_music return [play_command] @@ -59,13 +58,12 @@ class PlayPlugin(BeetsPlugin): command_str = config['play']['command'].get() use_folders = config['play']['use_folders'].get(bool) relative_to = config['play']['relative_to'].get() - confargs = config['play']['args'].get() if relative_to: relative_to = util.normpath(relative_to) - # Prepare command strings with optional args - command_str = command_str.format(opts.args or '')\ - .format(confargs or '') + # Add optional arguments to the player command. + if opts.args: + command_str = "{} {}".format(command_str, opts.args) # Perform search by album and add folders rather than tracks to # playlist. @@ -117,6 +115,7 @@ class PlayPlugin(BeetsPlugin): ui.print_(u'Playing {0} {1}.'.format(len(selection), item_type)) + self._log.debug('executing command: {} {}', command_str, m3u.name) try: util.interactive_open(m3u.name, command_str) except OSError as exc: diff --git a/docs/plugins/play.rst b/docs/plugins/play.rst index 45c8ab641..b856d5e6f 100644 --- a/docs/plugins/play.rst +++ b/docs/plugins/play.rst @@ -29,12 +29,6 @@ would on the command-line):: While playing you'll be able to interact with the player if it is a command-line oriented, and you'll get its output in real time. -The ``--args``-argument can be used to pass additional parameters to the -command. The position for these is marked by ``{}`` in the command-section. - -For additional features and usage of the ``--args``-argument, see the example -below. - Configuration ------------- @@ -50,36 +44,10 @@ configuration file. The available options are: paths to each track on the matched albums. Enable this option to store paths to folders instead. Default: ``no``. -- **optargs**: Static, additional parameters that may be inserted - using ``--args``. For this to work, you need ``{}`` inserted into your - command-section of the config file as well as into the parameter given to - ``--args`` (see example) -Args-Example ------------- +Optional Arguments +------------------ -Assume you have the following in your config file:: - - play: - command: player --opt1 arg1 {} --opt2 - args: --opt3 - -If you just call ``beet play`` without the usage of ``--args``, the command -will be called as if the ``{}`` wasn't there:: - - player --opt1 arg1 --opt2 - -If ``--args`` is given, the ``{}`` gets replaced by the argument, thus -``beet play --args "--opt4"`` results in a call of:: - - player --opt1 arg1 --opt4 --opt2 - -To insert the options configured with the args-key in the config-file, -call ``beet play --args "{}"``, resulting in:: - - player --opt1 arg1 --opt3 --opt2 - -Of course, this can be combined with other parameters as well, like in -``beet play --args "{} --opt4"``, which calls the following:: - - player --opt1 arg1 --opt3 --opt4 --opt2 +The ``--args`` (or ``-A``) flag to the ``play`` command lets you specify +additional arguments for your player command. Options are inserted after the +configured ``command`` string and before the playlist filename.