-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added a terminal bell if interaction from the user is required, according to this issue: https://github.com/beetbox/beets/issues/2366 #2495
Conversation
@SpirosChadoulos, thanks for your PR! By analyzing the history of the files in this pull request, we identified @sampsyo, @pkess and @geigerzaehler to be potential reviewers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for getting this started, and congratulations on your first beets PR!
Even though this is a small change, I have a couple of requests:
- This method isn't quite the right place to emit the bell. This method just generates the list of choices to emit; it doesn't actually display the prompt. The bell should definitely be printed right next to the code that actually emits the prompt. Namely, this happens with a call to
ui.input_options
in thechoose_candidate
function in the same file. - Please put this new functionality behind a configuration option. (I, personally, don't want a bell ringing on every prompt.)
beets/ui/commands.py
Outdated
@@ -823,6 +823,8 @@ def _get_choices(self, task): | |||
Returns a list of `PromptChoice`s. | |||
""" | |||
# Standard, built-in choices. | |||
#Bell ring to alert the user that he has to interfere with the cmd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This Travis report: https://travis-ci.org/beetbox/beets/jobs/215295136#L885
is telling you to put a space after the #
character in your comments. In addition, please use complete sentences in comments that end with periods—and there's no need to use abbreviations like "cmd".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay I'll work on it. Thank you.
I put the command in the right place and I fixed my comment. Could you give me some instractions on how to put this new functionality behind a configuration option? |
Sure! You might try looking around how other boolean operations are implemented. For example, this conditional implements the if config['import']['bell']:
... and then add a default value to |
…'s configuration.
@sampsyo I made tha changes you requested..Is my branch ready to be marged to the main beets repo? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! I requested a few small changes above. After that, we'll also need an entry in the changelog describing what's new. With all that in place, this will be ready to merge! ✨
beets/config_default.yaml
Outdated
@@ -25,6 +25,7 @@ import: | |||
pretend: false | |||
search_ids: [] | |||
duplicate_action: ask | |||
bell: yes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's have this default to "no" (to avoid surprising people who upgrade).
docs/reference/config.rst
Outdated
bell | ||
~~~~~~~~~~~~~~~~ | ||
|
||
Whether the importer ui should ring a bell when user interaction is needed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggested simpler wording:
Ring the terminal bell to get your attention when the importer needs your input.
docs/reference/config.rst
Outdated
|
||
Whether the importer ui should ring a bell when user interaction is needed. | ||
|
||
Default: ``yes``. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(If the default is changed, this needs changing too.)
beets/ui/commands.py
Outdated
@@ -613,6 +613,9 @@ def choose_candidate(candidates, singleton, rec, cur_artist=None, | |||
}) | |||
if default is None: | |||
require = True | |||
# Bell ring when user interaction is needed. | |||
if config['import']['bell']: | |||
print('\a') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to add an extra newline, in addition to ringing the bell. Perhaps you mean print('\a', end='')
?
Also, all output from the commands needs to go through our custom ui.print_
function instead of the built-in print
for dumb encoding reasons. Could you please use that function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't get the changelog describing part..What sould I do?
@sampsyo I did the new changes you told me. Is everything okay? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! Thank you again! ✨ I added a changelog entry.
@sampsyo Thanks a lot. Why next to the pull request there is a red x? |
Hmm… which "x" are you referring to? If you mean the one next to the commit hash for the latest commit, it looks like that's because the AppVeyor build was canceled when I merged the PR. (You can hover over the "x" to see the details.) |
Isn't it a problem that AppVeyor didnt' complete? |
In this case, no. I merged the PR before the build had a chance to complete (because I already new it would succeed); AppVeyor then canceled the build. No harm, no foul. (If you like, you can see on the main branch commit history that things are still passing.) |
Okay thanks a lot. |
Fixes #2366.