o
    i                     @   sP   d dl mZ erd dlmZ G dd dZG dd deZe Zeddd	Zd
S )    )TYPE_CHECKING)ArgumentCollectionc                   @   s8   e Zd Z			ddededB defddZdddZdS )LimitedChoicer   NFminmax
allow_nonec                 C   s<   || _ |du r| j pdn|| _| j| j k rtd|| _dS )a  Group validator that limits the number of selections per group.

        Commonly used for enforcing mutually-exclusive parameters (default behavior).

        Parameters
        ----------
        min: int
            The minimum (inclusive) number of CLI parameters allowed.
            If negative, then **all** parameters in the group must have CLI values provided.
        max: int | None
            The maximum (inclusive) number of CLI parameters allowed.
            Defaults to ``1`` if ``min==0``, ``min`` otherwise.
        allow_none: bool
            If :obj:`True`, also allow 0 CLI parameters (even if ``min`` is greater than 0).
            Defaults to :obj:`False`.
        N   zmax must be >=min.)r   r   
ValueErrorr   )selfr   r   r    r   `/var/www/html/karishye-ai-python/venv/lib/python3.10/site-packages/cyclopts/validators/_group.py__init__   s    
zLimitedChoice.__init__argument_collectionr   c           	   
   C   s  t |}|jdd}t |}| jr|dkrd S | jdk rL||kr"d S dd |D }dd |D }t|| }t |dkrEtd|d  td	| | j|  krY| jkrZd S  d
ddd |D  d }| jdkry| jdkrytd| td| d| d| j d| j d	)NT)	value_setr   c                 S      h | ]}|j qS r   name.0ar   r   r   	<setcomp>/       z)LimitedChoice.__call__.<locals>.<setcomp>c                 S   r   r   r   r   r   r   r   r   0   r   r   zMissing argument: zMissing arguments: {z, c                 s   s4    | ]}|j r|j d  jr|j d  jn|jV  qdS )r   N)tokenskeywordr   r   r   r   r   	<genexpr>;   s
    "
z)LimitedChoice.__call__.<locals>.<genexpr>}zMutually exclusive arguments: z	Received z arguments: z. Only [z] choices may be specified.)len	filter_byr   r   sortedr	   r   join)	r
   r   
group_sizepopulated_argument_collectionn_arguments	all_namessupplied_namesmissing_names	offendersr   r   r   __call__$   s<   

 zLimitedChoice.__call__)r   NF)r   r   )__name__
__module____qualname__intboolr   r(   r   r   r   r   r      s    
r   c                       s   e Zd Z fddZ  ZS )MutuallyExclusivec                    s   t    dS )zAlias for :class:`LimitedChoice` to make intentions more obvious.

        Only 1 argument in the group can be supplied a value.
        N)superr   )r
   	__class__r   r   r   J   s   zMutuallyExclusive.__init__)r)   r*   r+   r   __classcell__r   r   r0   r   r.   I   s    r.   T)r   N)typingr   cyclopts.argumentr   r   r.   mutually_exclusiveall_or_noner   r   r   r   <module>   s    B	