
    Pi,                        d Z ddlmZ ddlmZmZ dgZ eh d          Z eh d          Z	 eddh          Z
 ed	d
h          ZddZddZddZdS )a  
Packer command handler for Dippy.

Packer is a HashiCorp tool for building automated machine images.

Safe operations are read-only inspections and validations.
Unsafe operations include building images (external effects),
installing plugins, and modifying template files.
    )annotations)ClassificationHandlerContextpacker>   consoleinspectversionvalidate>   fixinitbuildhcl2_upgrade	installedrequiredinstallremovectxr   returnr   c                j   | j         }|r|d         nd}t          |          dk     rt          d|          S d|v sd|v sd|v rt          d	| d
          S d|v sd|v rt          d	| d          S d}d}|t          |          k     r&||         }|                    d          r|dz  }6|}	 |st          d|          S |dz   t          |          k     r||dz   d         ng }| d| }|dk    r]t	          |          }|r| d| }|t
          v rt          d	|          S |t          v rt          d|          S t          d|          S |dk    r1t          |          rt          d	|          S t          d|          S |t          v rt          d	|          S t          d|          S )zClassify packer command.r   r      ask)descriptionz--helpz-helpz-hallowz --helpz	--versionz-versionz
 --versionN   - pluginsfmt)	tokenslenr   
startswith_find_subcommandSAFE_PLUGINS_SUBCOMMANDSUNSAFE_PLUGINS_SUBCOMMANDS_is_fmt_safeSAFE_ACTIONS)	r   r   baseaction
action_idxtokenrestdesc
subcommands	            1/root/projects/gits/Dippy/src/dippy/cli/packer.pyclassifyr/   6   sQ   ZF,6!99HD
6{{Qe6666 6W..$&..gd3C3C3CDDDD f
f 4 4gd3F3F3FGGGG FJ
s6{{
"
"z"C   	!OJ 7e6666'1A~F'C'C6*q.""##DVD %d++
 	*))Z))D111!'t<<<<333!%T::::e6666  	=!'t<<<<e6666 g48888%T2222    r+   	list[str]
str | Nonec                B    | D ]}|                     d          s|c S dS )z/Find the first non-flag token (the subcommand).r   Nr!   r+   r*   s     r.   r"   r"   q   s:      $$ 	LLL	4r0   boolc                H    | D ]}|dv s|                     d          r dS dS )z.Check if fmt command is safe (read-only mode).>   -diff-checkz-write=falseTFr4   r5   s     r.   r%   r%   y   sA      '''5+;+;N+K+K'44 (5r0   N)r   r   r   r   )r+   r1   r   r2   )r+   r1   r   r6   )__doc__
__future__r   	dippy.clir   r   COMMANDS	frozensetr&   UNSAFE_ACTIONSr#   r$   r/   r"   r%    r0   r.   <module>rA      s    # " " " " " 4 4 4 4 4 4 4 4: y        %9   'Y  83 83 83 83v        r0   