Ticket #205: paste-ask-nodefault.diff

File paste-ask-nodefault.diff, 1.2 KB (added by ygingras, 5 years ago)

patch to add NoDefault? support in Command.ask()

  • paste/script/command.py

     
    242242 
    243243    def ask(self, prompt, safe=False, default=True): 
    244244        """ 
    245         Prompt the user.  Default can be true, false, ``'careful'`` or 
    246         ``'none'``.  If ``'none'`` then the user must enter y/n.  If 
    247         ``'careful'`` then the user must enter yes/no (long form). 
     245        Prompt the user.  Default can be true, false, ``'careful'``, 
     246        ``'none'``, or the ``NoDefault`` class.  If ``'none'`` or 
     247        ``NoDefault`` then the user must enter y/n.  If ``'careful'`` 
     248        then the user must enter yes/no (long form). 
    248249 
    249250        If the interactive option is over two (``-ii``) then ``safe`` 
    250251        will be used as a default.  This option should be the 
     
    256257            default = safe 
    257258        if default == 'careful': 
    258259            prompt += ' [yes/no]?' 
    259         elif default == 'none': 
     260        elif default == 'none' or default == NoDefault: 
    260261            prompt += ' [y/n]?' 
    261262        elif default: 
    262263            prompt += ' [Y/n]? '