Inquirer.js icon indicating copy to clipboard operation
Inquirer.js copied to clipboard

Feat (password): add option to toggle password visibility

Open matteosacchetto opened this issue 2 years ago • 7 comments

Implementation of the feature request idea #1330

Steps:

  • [x] Add basic functionality to skip the transform function
  • [x] Add option to show or hide the password
  • [x] Add tests
  • [ ] Add documentation
  • [ ] Decide the shortcut to use
  • [ ] Decide how to manage the UX

matteosacchetto avatar Nov 19 '23 15:11 matteosacchetto

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (11bbb4b) 94.48% compared to head (ae62463) 94.54%. Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1334      +/-   ##
==========================================
+ Coverage   94.48%   94.54%   +0.06%     
==========================================
  Files          51       51              
  Lines        4457     4476      +19     
  Branches      775      780       +5     
==========================================
+ Hits         4211     4232      +21     
+ Misses        241      239       -2     
  Partials        5        5              

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Nov 19 '23 15:11 codecov[bot]

I started implementing the feature request of #1330 I still have to add tests, and handle the UX

Moreover, we also need to decide how we should call the new options

matteosacchetto avatar Nov 19 '23 15:11 matteosacchetto

@SBoudrias is there a way to test keyboard combinations, like CTRL + space?

matteosacchetto avatar Nov 19 '23 16:11 matteosacchetto

is there a way to test keyboard combinations, like CTRL + space?

Not at the moment, we should definitively add it to the testing library though!

SBoudrias avatar Nov 21 '23 21:11 SBoudrias

is there a way to test keyboard combinations, like CTRL + space?

Not at the moment, we should definitively add it to the testing library though!

I will look into this further, since I think is not that difficult to add to the library, and it would allow us to write tests for this new feature

matteosacchetto avatar Nov 22 '23 09:11 matteosacchetto

is there a way to test keyboard combinations, like CTRL + space?

Not at the moment, we should definitively add it to the testing library though!

I will look into this further, since I think is not that difficult to add to the library, and it would allow us to write tests for this new feature

Quick update: to allow for testing keyboard combinations is relatively easy to implement. We just need to add to @inquirer/testing an additional event, which exposes all the parameters a 'keypress' event supports

export interface Key {
  name?: string | undefined;
  ctrl?: boolean | undefined;
  meta?: boolean | undefined;
  shift?: boolean | undefined;
}

We just need to decide whether to implement a new function, modify the current keypress without a breaking change or modify it with a breaking change. I would say it would be better to implement a new function or to modify the keypress function without introducing a breaking change, since the option of passing keyboard combinations/shortcuts is less used than passing normal key presses

matteosacchetto avatar Nov 22 '23 23:11 matteosacchetto

Separating the rewrite from the new feature was the right choice!

I'm still experimenting with ideas on how to implement this feature but I have not yet found something which works consistently between different terminals

I think that if we want to ship this feature, in the end we need to find a shortcut which works on most of them and accept that in some environments it won't work as expected

If only there was a way to get which keyboard shortcuts are available in a give environment...

matteosacchetto avatar Jan 27 '24 19:01 matteosacchetto