Skip to content

Commit ca359d7

Browse files
authored
Merge pull request beetbox#3085 from jackwilsdon/modify-skip-remaining
Allow exiting object selection early
2 parents 17d9882 + bed3abd commit ca359d7

File tree

4 files changed

+23
-5
lines changed

4 files changed

+23
-5
lines changed

beets/ui/__init__.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -408,9 +408,14 @@ def input_select_objects(prompt, objs, rep):
408408
out = []
409409
for obj in objs:
410410
rep(obj)
411-
if input_yn(u'%s? (yes/no)' % prompt, True):
411+
answer = input_options(
412+
('y', 'n', 'q'), True, u'%s? (yes/no/quit)' % prompt,
413+
u'Enter Y or N:'
414+
)
415+
if answer == u'y':
412416
out.append(obj)
413-
print() # go to a new line
417+
elif answer == u'q':
418+
return out
414419
return out
415420

416421
else: # No.

docs/changelog.rst

+2
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ New features:
4646
example, ``beet modify -a artist:beatles artpath!`` resets ``artpath``
4747
attribute from matching albums back to the default value.
4848
:bug:`2497`
49+
* Modify selection can now be applied early without selecting every item.
50+
:bug:`3083`
4951

5052
Changes:
5153

docs/reference/cli.rst

+4-3
Original file line numberDiff line numberDiff line change
@@ -269,9 +269,10 @@ affected items in the library and asks for your permission before making any
269269
changes. You can then choose to abort the change (type `n`), confirm
270270
(`y`), or interactively choose some of the items (`s`). In the latter case,
271271
the command will prompt you for every matching item or album and invite you to
272-
type `y` or `n`. This option lets you choose precisely which data to change
273-
without spending too much time to carefully craft a query. To skip the prompts
274-
entirely, use the ``-y`` option.
272+
type `y` to apply the changes, `n` to discard them or `q` to exit and apply
273+
the selected changes. This option lets you choose precisely which data to
274+
change without spending too much time to carefully craft a query. To skip the
275+
prompts entirely, use the ``-y`` option.
275276

276277
.. _move-cmd:
277278

test/test_ui_init.py

+10
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,16 @@ def test_input_select_objects(self):
7373
lambda s: self._print_helper2(s, "Prefix"))
7474
self.assertEqual(items, ['1', '2', '4'])
7575

76+
# Test selective 3
77+
self.io.addinput('s')
78+
self.io.addinput('y')
79+
self.io.addinput('n')
80+
self.io.addinput('y')
81+
self.io.addinput('q')
82+
items = ui.input_select_objects(
83+
"Prompt", full_items, self._print_helper)
84+
self.assertEqual(items, ['1', '3'])
85+
7686

7787
class InitTest(_common.LibTestCase):
7888
def setUp(self):

0 commit comments

Comments
 (0)