
    =                     F    S r SSKrSSKJr   " S S\R                  5      rg)zProvides an ArgType for --preset flags.

This is a custom ArgType for the --preset flag that allows users to specify a
preset name with a dictionary of parameters for that preset.

Example:
  --preset my-preset:key1=value1,key2=value2
    N)arg_parsersc                   R   ^  \ rS rSrSrSU 4S jjrU 4S jr\S 5       rS r	Sr
U =r$ )		PresetArg   zInterpret argument as a named dict.

The string before the colon is the preset name and the string after is a
dictionary of parameters for the preset.

  --preset my-preset:key1=value1,key2=value2
c                 z   > [         TU ]  XUS9  Sn[        R                  " U[        R                  5      U l        g )N)key_type
value_typecleanup_inputz([^:]+)(:?)(.*))super__init__recompileDOTALLpreset_arg_matcher)selfr   r	   r
   preset_param_pattern	__class__s        0lib/googlecloudsdk/command_lib/run/preset_arg.pyr   PresetArg.__init__&   s:    	G   - jj)=ryyID    c                    > U R                   R                  U5      nU(       d%  [        R                  " SR	                  U5      5      eUR                  S5      n[        TU ]  UR                  S5      5      nX4S.$ )Nz]Invalid preset value [{0}], expected format is <preset_name>:<key1>=<value1>,<key2>=<value2>.      )nameparams)r   matchr   ArgumentTypeErrorformatgroupr   __call__)r   	arg_valuer   preset_nameparams_dictr   s        r   r    PresetArg.__call__-   sm    ##)))4E))<<BF9<M  ++a.K'"5;;q>2K77r   c                     g)NF )r   s    r   hiddenPresetArg.hidden8   s    r   c                     AU$ )Nr&   )r   is_custom_metavarmetavars      r   GetUsageMetavarPresetArg.GetUsageMetavar<   s
    Nr   )r   )NNT)__name__
__module____qualname____firstlineno____doc__r   r    propertyr'   r,   __static_attributes____classcell__)r   s   @r   r   r      s1    J	8   r   r   )r2   r   googlecloudsdk.callioper   ArgDictr   r&   r   r   <module>r8      s$    
 /!## !r   