Skip to content
This repository has been archived by the owner on Mar 31, 2024. It is now read-only.

Commit

Permalink
Support password inputs in textui.prompt.query
Browse files Browse the repository at this point in the history
  • Loading branch information
j00bar committed Apr 17, 2015
1 parent 140d858 commit a09b1ef
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions clint/textui/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from __future__ import absolute_import, print_function

from re import match, I
import getpass

from .core import puts
from .colored import yellow
Expand Down Expand Up @@ -59,7 +60,7 @@ def yn(prompt, default='y', batch=False):
return True if default == 'n' else False


def query(prompt, default='', validators=None, batch=False):
def query(prompt, default='', validators=None, batch=False, mask_input=False):
# Set the nonempty validator as default
if validators is None:
validators = [RegexValidator(r'.+')]
Expand All @@ -76,7 +77,8 @@ def query(prompt, default='', validators=None, batch=False):
# If batch option is True then auto reply
# with default input
if not batch:
user_input = raw_input(prompt).strip() or default
user_input_fn = getpass.getpass if mask_input else raw_input
user_input = user_input_fn(prompt).strip() or default
else:
print(prompt)
user_input = ''
Expand Down

0 comments on commit a09b1ef

Please sign in to comment.