CITGuru / PyInquirer

A Python module for common interactive command line user interfaces
MIT License
1.91k stars 236 forks source link

expand: help by default #65

Closed tjb1982 closed 4 years ago

tjb1982 commented 5 years ago

I broke the self.choices collection code into two parts:

  1. append the choices in "normalized" form
  2. select an appropriate default

This requires mutation of the key, so I changed the type from tuple to list, which in this case is functionally equivalent except that tuples are immutable.

The other piece that was missing had to do with h/H keys being handled differently than a standard choice (i.e., the _help_active flag is set), so I added a conditional in set_answer for that, which allows users to hit Enter without None becoming the selected value. The choice to use a special "__HELP__" value is to avoid disallowing users to choose None as a value, which also seems to be how KeyboardInterrupt (Ctrl-C) is handled.

tjb1982 commented 5 years ago

fixes #50