Repository: beetbox/beets

Issue:
Selection interface: option to "skip remaining tracks" and take action
### Problem

I love the `modify` command's select mode, because it means you don't have to write super-specific queries - instead you can write a more general query and then simply type an `n` to skip those tracks you don't want to retag.

Unfortunately, there seems to be no way to "skip remaining tracks". For example, say I got through 50 out of 100 tracks that a query returned. I've answered `y` to most of them, but `n` to just a few. If I hit Ctrl-C at this point, I notice that the tags do not get written to the tracks I answered `y` to.

Perhaps we could add an `s` option that skips remaining tracks but still updates those that we answered `y` to. Alternatively, we could update tracks as-and-when we answer `y`, allowing us to Ctrl-C out of the process without losing work.

Discussion:

Patch:
diff --git a/beets/ui/__init__.py b/beets/ui/__init__.py
index d3c3dafc2..1abce2e67 100644
--- a/beets/ui/__init__.py
+++ b/beets/ui/__init__.py
@@ -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.
diff --git a/docs/changelog.rst b/docs/changelog.rst
index 61e244310..657d2a86e 100644
--- a/docs/changelog.rst
+++ b/docs/changelog.rst
@@ -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:
 
diff --git a/docs/reference/cli.rst b/docs/reference/cli.rst
index 39a4b3f10..7b9e9eb72 100644
--- a/docs/reference/cli.rst
+++ b/docs/reference/cli.rst
@@ -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:
 


Test patch:
diff --git a/test/test_ui_init.py b/test/test_ui_init.py
index 3a146b0c0..41f167193 100644
--- a/test/test_ui_init.py
+++ b/test/test_ui_init.py
@@ -73,6 +73,16 @@ class InputMethodsTest(_common.TestCase):
             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):