-
-
Notifications
You must be signed in to change notification settings - Fork 402
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
dice: clean up the dice "choose" command output (fix #1420) #1425
Conversation
This looks good so far! I'm just going to leave a note, for now, but it doesn't need to be addressed immediately. It can wait until after Sopel 6.6.0 is (finally) released. Commit fb4eb44 duplicates what #1421 does, just in a slightly different way. This PR should be amended (eventually) to make sure only one |
Yes indeed! It'll be done. |
233b274
to
2d8c0fd
Compare
First rebase, just to clean up the |
2d8c0fd
to
358be32
Compare
Second rebase, to change the output delimiter to the discussed one (only comma, quote when needed). @dgw it should be good now! |
The `.choose` command's output adds a space after the delimiter: this works fine after a comma, but not with other delimiters (|, /, and \). Instead, we use only the comma as a delimiter, and to prevent ambiguity, we add quotation marks when needed: [nick] .choose a|b|c [Sopel] Your options: a, b, c. My choice: a [nick] .choose a,b,c [Sopel] Your options: a, b, c. My choice: c [nick] .choose a, b | just a [Sopel] Your options: "a, b", just a. My choice: a, b
It is now possible to use the space as a delimiter: [nick] .choose a b c [Sopel] Your options: a, b, c. My choice: c It is a last-resort delimiter.
358be32
to
c521b97
Compare
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.
So, I did manage to trip this up with quoted input:
<dgw> .ch "foo, bar", spam, "egg, bacon"
<Sopel> dgw: Your options: "foo, bar", spam, "egg, bacon". My choice: "egg
But… I don't think handling that kind of case is worth it. This is actually exactly why the module supports so many delimiters. Using something other than ,
between items works just fine:
<dgw> .ch "foo, bar"|spam|"egg, bacon"
<Sopel> dgw: Your options: ""foo, bar"", spam, ""egg, bacon"". My choice: "foo, bar"
The nested quotes look a little weird, admittedly, but this is going to be an exceedingly rare case. So I'm not going to mind it. We can always come back to this function post-7.0.0 if it turns out to be an issue.
See issue #1420 and PR #1421 that I used as my starting point.
Following my comment on #1420 I decided to go with a PR that:
\s
as a last-resort delimiter, because why not,which improve coverage and make for a better output.
EDIT: we discussed another option, which I implemented afterward, to use comma as an output delimiter in all cases and to add quotation marks when needed.
Example with comma
,
:Example with comma
,
(without spaces):Example with pipe
|
:Example with pipe
|
(without spaces):Example with space
\s
:Example with pipe
|
but there are comma in some options: