Skip to content

Commit

Permalink
Merge pull request beetbox#3085 from jackwilsdon/modify-skip-remaining
Browse files Browse the repository at this point in the history
Allow exiting object selection early
  • Loading branch information
sampsyo authored Dec 2, 2018
2 parents 17d9882 + bed3abd commit ca359d7
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
9 changes: 7 additions & 2 deletions beets/ui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,9 +408,14 @@ def input_select_objects(prompt, objs, rep):
out = []
for obj in objs:
rep(obj)
if input_yn(u'%s? (yes/no)' % prompt, True):
answer = input_options(
('y', 'n', 'q'), True, u'%s? (yes/no/quit)' % prompt,
u'Enter Y or N:'
)
if answer == u'y':
out.append(obj)
print() # go to a new line
elif answer == u'q':
return out
return out

else: # No.
Expand Down
2 changes: 2 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ New features:
example, ``beet modify -a artist:beatles artpath!`` resets ``artpath``
attribute from matching albums back to the default value.
:bug:`2497`
* Modify selection can now be applied early without selecting every item.
:bug:`3083`

Changes:

Expand Down
7 changes: 4 additions & 3 deletions docs/reference/cli.rst
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,10 @@ affected items in the library and asks for your permission before making any
changes. You can then choose to abort the change (type `n`), confirm
(`y`), or interactively choose some of the items (`s`). In the latter case,
the command will prompt you for every matching item or album and invite you to
type `y` or `n`. This option lets you choose precisely which data to change
without spending too much time to carefully craft a query. To skip the prompts
entirely, use the ``-y`` option.
type `y` to apply the changes, `n` to discard them or `q` to exit and apply
the selected changes. This option lets you choose precisely which data to
change without spending too much time to carefully craft a query. To skip the
prompts entirely, use the ``-y`` option.

.. _move-cmd:

Expand Down
10 changes: 10 additions & 0 deletions test/test_ui_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,16 @@ def test_input_select_objects(self):
lambda s: self._print_helper2(s, "Prefix"))
self.assertEqual(items, ['1', '2', '4'])

# Test selective 3
self.io.addinput('s')
self.io.addinput('y')
self.io.addinput('n')
self.io.addinput('y')
self.io.addinput('q')
items = ui.input_select_objects(
"Prompt", full_items, self._print_helper)
self.assertEqual(items, ['1', '3'])


class InitTest(_common.LibTestCase):
def setUp(self):
Expand Down

0 comments on commit ca359d7

Please sign in to comment.