
    Ri                     8    d dl mZmZmZmZ  G d d          ZdS )    )AnyIterableOptionalTuplec                      e Zd ZdZddeddddddf	dee         dee         dedee         d	ee         d
edededee         ddfdZ	defdZ
edee         fd            Zedeedf         fd            Zedefd            Zedefd            Zej        deddfd            ZddededdfdZedefd            ZdS )Argumenta\  
    A command-line argument/flag.

    :param name:
        Syntactic sugar for ``names=[<name>]``. Giving both ``name`` and
        ``names`` is invalid.
    :param names:
        List of valid identifiers for this argument. For example, a "help"
        argument may be defined with a name list of ``['-h', '--help']``.
    :param kind:
        Type factory & parser hint. E.g. ``int`` will turn the default text
        value parsed, into a Python integer; and ``bool`` will tell the
        parser not to expect an actual value but to treat the argument as a
        toggle/flag.
    :param default:
        Default value made available to the parser if no value is given on the
        command line.
    :param help:
        Help text, intended for use with ``--help``.
    :param positional:
        Whether or not this argument's value may be given positionally. When
        ``False`` (default) arguments must be explicitly named.
    :param optional:
        Whether or not this (non-``bool``) argument requires a value.
    :param incrementable:
        Whether or not this (``int``) argument is to be incremented instead of
        overwritten/assigned to.
    :param attr_name:
        A Python identifier/attribute friendly name, typically filled in with
        the underscored version when ``name``/``names`` contain dashes.

    .. versionadded:: 1.0
    N Fnamenameskinddefaulthelp
positionaloptionalincrementable	attr_namereturnc
                 8   |r|rt          d          |s|st          d          |rt          |          | _        n|r
|s|f| _        || _        d }
|t          u rg }
|r|}
|
x| _        | _        || _        || _        || _	        || _
        || _        |	| _        d S )Nz8Cannot give both 'name' and 'names' arguments! Pick one.z(An Argument must have at least one name.)	TypeErrortupler   r   list	raw_value_valuer   r   r   r   r   r   )selfr
   r   r   r   r   r   r   r   r   initial_values              N/srv/django_bis/venv311/lib/python3.11/site-packages/invoke/parser/argument.py__init__zArgument.__init__*   s      	E 	J    	H 	HFGGG 	!uDJJ 	!% 	!DJ	'+4<<M 	$#M'44	$ *"    c                 t   d}| j         r-d                    d                    | j                             }d}| j        s| j        rd}| j        r|dz  }| j        r|dz  }d}| j        t          k    rd                    | j        j                  }d                    | j        j        | j	        |||          S )	N z ({})z,  *?z [{}]z<{}: {}{}{}{}>)
	nicknamesformatjoinr   r   r   str__name__	__class__r
   )r   nicksflagsr   s       r   __repr__zArgument.__repr__P   s    > 	>NN499T^#<#<==E? 	dm 	E? 	SLE= 	SLE 9>>$)"455D&&N#TYtU
 
 	
r   c                 *    | j         p| j        d         S )z
        The canonical attribute-friendly name for this argument.

        Will be ``attr_name`` (if given to constructor) or the first name in
        ``names`` otherwise.

        .. versionadded:: 1.0
        r   )r   r   r   s    r   r
   zArgument.named   s     ~.A.r   .c                      | j         dd          S N   )r   r.   s    r   r$   zArgument.nicknamesp   s    z!""~r   c                 8    | j         t          u rdS | j        rdS dS )NFT)r   boolr   r.   s    r   takes_valuezArgument.takes_valuet   s)    95 	5tr   c                 ,    | j         | j         n| j        S N)r   r   r.   s    r   valuezArgument.value|   s     #k5t{{4<Gr   argc                 4    |                      |d           d S )NT)cast)	set_value)r   r8   s     r   r7   zArgument.value   s    s&&&&&r   Tr7   r:   c                      | _         d }|r j        } j        t          u r fd} j        r fd} ||           _        dS )a!  
        Actual explicit value-setting API call.

        Sets ``self.raw_value`` to ``value`` directly.

        Sets ``self.value`` to ``self.kind(value)``, unless:

        - ``cast=False``, in which case the raw value is also used.
        - ``self.kind==list``, in which case the value is appended to
          ``self.value`` instead of cast & overwritten.
        - ``self.incrementable==True``, in which case the value is ignored and
          the current (assumed int) value is simply incremented.

        .. versionadded:: 1.0
        c                     | S r6   r	   )xs    r   <lambda>z$Argument.set_value.<locals>.<lambda>   s     r   c                     j         | gz   S r6   r7   r>   r   s    r   r?   z$Argument.set_value.<locals>.<lambda>   s    TZ1#- r   c                     j         dz   S r0   rA   rB   s    r   r?   z$Argument.set_value.<locals>.<lambda>   s    TZ!^ r   N)r   r   r   r   r   )r   r7   r:   funcs   `   r   r;   zArgument.set_value   sk      { 	9D9----D 	, ,+++Dd5kkr   c                 X    | j         t          u rt          | j                  S | j        duS )a/  
        Returns whether the argument was ever given a (non-default) value.

        For most argument kinds, this simply checks whether the internally
        stored value is non-``None``; for others, such as ``list`` kinds,
        different checks may be used.

        .. versionadded:: 1.3
        N)r   r   r3   r   r.   s    r   	got_valuezArgument.got_value   s.     9$$${$&&r   )T)r(   
__module____qualname____doc__r'   r   r   r   r3   r   r,   propertyr
   r   r$   r4   r7   setterr;   rF   r	   r   r   r   r      s          H #!!%" ##'$# $#sm$# }$# 	$#
 #$# sm$# $# $# $# C=$# 
$# $# $# $#L
# 
 
 
 
( 	/hsm 	/ 	/ 	/ X	/ 5c?    X T    X Hs H H H XH \' ' ' ' ' \'" "s "$ "$ " " " "@ '4 ' ' ' X' ' 'r   r   N)typingr   r   r   r   r   r	   r   r   <module>rM      se    1 1 1 1 1 1 1 1 1 1 1 1k' k' k' k' k' k' k' k' k' k'r   