o
    Th                     @   s*   d dl mZmZmZmZ G dd dZdS )    )AnyIterableOptionalTuplec                   @   s  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dZ	defddZ
edee fddZedeedf fddZedefddZedefddZejdeddfddZd%ded eddfd!d"Zedefd#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
                 C   s   |r|rt d|s|st d|rt|| _n|r |s |f| _|| _d }
|tu r+g }
|r/|}
|
 | _| _|| _|| _|| _	|| _
|| _|	| _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_valuer   r   I/var/www/html/venv/lib/python3.10/site-packages/invoke/parser/argument.py__init__*   s.   
zArgument.__init__c                 C   s   d}| j rdd| j }d}| js| jrd}| jr|d7 }| jr&|d7 }d}| jtkr4d| jj}d| jj| j	|||S )	N z ({})z,  *?z [{}]z<{}: {}{}{}{}>)
	nicknamesformatjoinr   r   r
   str__name__	__class__r   )r   nicksflagsr
   r   r   r   __repr__P   s    
zArgument.__repr__c                 C   s   | 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   r   r   r   r   d   s   
zArgument.name.c                 C   s   | j dd  S N   )r	   r(   r   r   r   r   p   s   zArgument.nicknamesc                 C   s   | j tu rdS | jrdS dS )NFT)r
   boolr   r(   r   r   r   takes_valuet   s
   
zArgument.takes_valuec                 C   s   | j d ur| j S | jS N)r   r   r(   r   r   r   value|   s   zArgument.valueargc                 C   s   | j |dd d S )NT)cast)	set_value)r   r/   r   r   r   r.      s   Tr.   r0   c                    sN   | _ dd }|r j} jtu r fdd} jr  fd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   s   | S r-   r   xr   r   r   <lambda>   s    z$Argument.set_value.<locals>.<lambda>c                    s    j | g S r-   r.   r2   r(   r   r   r4      s    c                    s
    j d S r)   r5   r2   r(   r   r   r4      s   
 N)r   r
   r   r   r   )r   r.   r0   funcr   r(   r   r1      s   
zArgument.set_valuec                 C   s   | 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   r+   r   r(   r   r   r   	got_value   s   


zArgument.got_value)T)r#   
__module____qualname____doc__r"   r   r   r   r+   r   r'   propertyr   r   r   r,   r.   setterr1   r7   r   r   r   r   r      s\    $	

& r   N)typingr   r   r   r   r   r   r   r   r   <module>   s    