U
    6eJ	                     @   s<   d Z ddlmZ dgZdZd	eee eee dddZdS )
z
Interaction
~~~~~~~~~~~
    )Optionalconfirm   NF)actiondefaultskipreturnc           	      C   s   |r|S dddd}|| \}}|  d| d| d}d}z8|dkrhd	}|sp|t k rpt|}|d	7 }qHnt|}W n tk
r   Y dS X |d
krdS |dkrdS |dk	r|S dS )a;  
    A shortcut for typical confirmation prompt.

    :param action:

        a string describing the action, e.g. "Apply changes". A question mark
        will be appended.

    :param default:

        `bool` or `None`. Determines what happens when user hits :kbd:`Enter`
        without typing in a choice. If `True`, default choice is "yes". If
        `False`, it is "no". If `None`, the prompt keeps reappearing until user
        types in a choice (not necessarily acceptable) or until the number of
        iteration reaches the limit. Default is `None`.

    :param skip:

        `bool`; if `True`, no interactive prompt is used and default choice is
        returned (useful for batch mode). Default is `False`.

    Usage::

        def delete(key, *, silent=False):
            item = db.get(Item, args.key)
            if confirm(f"Delete {item.title}", default=True, skip=silent):
                item.delete()
                print("Item deleted.")
            else:
                print("Operation cancelled.")

    Returns `None` on `KeyboardInterrupt` event.
    )yn)Yr
   )r	   N)NTFz? (/)N   )Zyesr	   r   T)nor
   r   F)MAX_CONFIRM_ITERATIONSinputKeyboardInterrupt)	r   r   r   defaultsZ	label_yesZlabel_nopromptchoiceZcnt r   /lib/python3.8/site-packages/argh/interaction.pyr      s2    $)NF)__doc__typingr   __all__r   strboolr   r   r   r   r   <module>
   s        