
    Ki                     l    d dl mZ erd dlmZ  G d d      Z G d de      Z e       Z edd	      Zy
)    )TYPE_CHECKING)ArgumentCollectionc                   6    e Zd Z	 	 	 ddededz  defdZddZy)	LimitedChoiceNminmax
allow_nonec                     || _         || j                   xs dn|| _        | j                  | j                   k  rt        d      || _        y)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	   s       f/home/jay/workspace/scripts/.codegraph-venv/lib/python3.12/site-packages/cyclopts/validators/_group.py__init__zLimitedChoice.__init__   sC    , &)kDHHMs88dhh122$    c                    t        |      }|j                  d      }t        |      }| j                  r|dk(  ry | j                  dk  rs||k(  ry |D ch c]  }|j                   }}|D ch c]  }|j                   }}t        ||z
        }t        |      dk(  rt        d|d          t        d|       | j                  |cxk  r| j                  k  ry  ddj                  d	 |D              z   d
z   }	| j                  dk(  r| j                  dk(  rt        d|	       t        d| d|	 d| j                   d| j                   d	      c c}w c c}w )NT)	value_setr   r   zMissing argument: zMissing arguments: {z, c              3      K   | ]N  }|j                   r2|j                   d    j                  r|j                   d    j                  n|j                   P yw)r   N)tokenskeywordname).0as     r   	<genexpr>z)LimitedChoice.__call__.<locals>.<genexpr>;   sH       -.HH!9L9LAHHQK''STSYSYYs   AA}zMutually exclusive arguments: z	Received z arguments: z. Only [z] choices may be specified.)	len	filter_byr	   r   r   sortedr   r   join)
r   argument_collection
group_sizepopulated_argument_collectionn_argumentsr   	all_namessupplied_namesmissing_names	offenderss
             r   __call__zLimitedChoice.__call__$   s   ,-
(;(E(EPT(E(U%78??{a/XX\[()<=A=I=.KLaffLNL"9~#=>M=!Q& #5mA6F5G!HII #6}o!FGGXX00 1 )) : 
   xx1}Q #A)!MNN }L8DHH:UWX\X`X`Waa|} + >Ls   E-E)r   NF)r    r   )__name__
__module____qualname__intboolr   r(    r   r   r   r      s7      	%% 4Z% 	%8"r   r   c                        e Zd Z fdZ xZS )MutuallyExclusivec                 "    t         |           y)zAlias for :class:`LimitedChoice` to make intentions more obvious.

        Only 1 argument in the group can be supplied a value.
        N)superr   )r   	__class__s    r   r   zMutuallyExclusive.__init__J   s    
 	r   )r)   r*   r+   r   __classcell__)r3   s   @r   r0   r0   I   s     r   r0   T)r	   N)typingr   cyclopts.argumentr   r   r0   mutually_exclusiveall_or_noner.   r   r   <module>r:      s<     4? ?D  '( B40r   