Skip to content
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

Improved confirm #65

Closed
wants to merge 2 commits into from
Closed

Conversation

chengdashun
Copy link

qq20170620-160928

@AydinHassan
Copy link
Member

Hi - thanks for the contribution , there are a few changes I would like to suggest. Please don't take that as discouragement and if you need some help just ask :)

Copy link
Member

@AydinHassan AydinHassan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally it needs some unit tests as well - maybe you could take a look at the existing ones for the confirm dialogue ?

@@ -8,6 +8,137 @@
class Confirm extends Dialogue
{

private $yesText = 'Yes';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think instead of changing the Confirm behaviour we could have a new dialogue type? maybe a YesNo dialogue ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. I like it


$promptWidth = mb_strlen($this->text) + 4;
$fillWidth = $promptWidth - (mb_strlen($this->getYesText()) + mb_strlen($this->getNoText()));
$placeHolderWidth = 0 == ($fillWidth % 2) ? 2 : 1;//中间位宽度
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we have this comment in english please?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, sorry, this is my first attempt to submit the code 😅

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem, take all the time you need and feel free to ask for any help! :)

@@ -163,6 +163,10 @@ public function getKeyedInput()
"\n" => 'enter',
"\r" => 'enter',
" " => 'enter',
"\033[D" => 'left',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these common values for navigating?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I need to confirm this

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not very sure,because the need for left and right arrow keys
The result is that I refer to the previous key-value debugging print out

@codecov-io
Copy link

Codecov Report

Merging #65 into master will decrease coverage by 9.93%.
The diff coverage is 0%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master      #65      +/-   ##
============================================
- Coverage     88.76%   78.83%   -9.94%     
- Complexity      239      254      +15     
============================================
  Files            18       18              
  Lines           730      822      +92     
============================================
  Hits            648      648              
- Misses           82      174      +92
Impacted Files Coverage Δ Complexity Δ
src/Dialogue/Confirm.php 36.69% <0%> (-63.31%) 17 <15> (+15)
src/Terminal/UnixTerminal.php 9.23% <0%> (-0.61%) 31 <0> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 870340f...75be242. Read the comment docs.

@chengdashun
Copy link
Author

😅 sorry PHP5.6 , 7 ,HHVM did not succeed, I am in the local test and then submit

@AydinHassan
Copy link
Member

Looking good @chengdashun ! I will try it out and push some unit tests to this branch and get it merged. I will ping you when I add the unit tests so maybe you can see how to do them in the future :)

@AydinHassan
Copy link
Member

@chengdashun I noticed that the options don't have padding around the < like the confirmation prompt does, could you maybe add those?

The confirmation prompt looks like:

< OK > whereas the YesNo prompt looks like <OK>

@simonschaufi
Copy link

@chengdashun Any update? I would love to use that confirm dialog as well!

@AydinHassan
Copy link
Member

Closing this due to lack of activity. Feel free to reopen, would be nice to have this feature!

@AydinHassan AydinHassan mentioned this pull request Oct 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants