Skip to content

Commit

Permalink
Correct boolean return value of prompt.yn
Browse files Browse the repository at this point in the history
Close #145
See also: #150
  • Loading branch information
tz70s authored and wkentaro committed Sep 24, 2015
1 parent 2bd5aef commit b575ebe
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions clint/textui/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,17 @@ def yn(prompt, default='y', batch=False):
input = ''

# If input is empty default choice is assumed
# so we return True
# We return True if default is 'y' , False otherwise
if input == '':
return True
return True if default == 'y' else False

# Given 'yes' as input if default choice is y
# then return True, False otherwise
# Return True if given 'yes' as input
if match('y(?:es)?', input, I):
return True if default == 'y' else False
return True

# Given 'no' as input if default choice is n
# then return True, False otherwise
# Return False if given 'no' as input
elif match('n(?:o)?', input, I):
return True if default == 'n' else False
return False


def query(prompt, default='', validators=None, batch=False):
Expand Down

0 comments on commit b575ebe

Please sign in to comment.