o
    :Fd                     @   s  d dl ZdZejejddZejedZdZg dZ	dd	gZ
d
dgZddgZe	e
 e e ZdddddddZddddddddddddddddddddddddddddddddddd ddd!ddd"dd#Zd$d%gZd&Zd'Zd(d) Zd*d+ ZdS ),    NZOCI_CLI_DISABLE_COLORS~z.ociz.cli-interactive-history
   )z	--profilez--config-filez--authz--regionz
--endpointz--cert-bundlez--auth-purposez-dz--debugz--cli-auto-promptz-iz--cli-rc-filez-?Zansicyanz#C74634Z	noreversez9#888888 bg:default noreverse noitalic nounderline noblinkz
fg:ansired) Zocizbottom-toolbarzbottom-toolbar.textzbottom-toolbar.errorzrequired-parameterZCompartment
identifier)resource_typefield_to_useZBucketnameZInstanceZVcnZVnic)r   r   ZSubnetZInstancePoolZDbSystemZ
BootVolumePolicyZUser)z-cz--compartment-idz--bucket-idz--bucket-namez-bnz--instance-idz--vcn-idz	--vnic-idz--subnet-idz--instance-pool-idz--db-system-idz--boot-volume-idz--policy-idz	--user-idzoci iam compartment listzoci iam user lista  Learn more about interactive features in CLI by watching our informative video on YouTube -> https://www.youtube.com/watch?v=lX29Xw1Te54&ab_channel=OracleLearning 
Also see https://docs.oracle.com/iaas/Content/API/SDKDocs/cliusing_topic-Using_Interactive_Mode.htmzsuggestion_variable.txtc                 C   s   d}t | d}| }|D ]}|dr|d7 }q|tkrE| d}t | d}||dd  W d   dS 1 s>w   Y  dS dS )	aL  
    This function validates the commands history file to make sure it does not exceed the limit
    for example if the limit is 50 commands, this function loops through the lines of the file, every command consists
    of 3 lines (one empty line, one line for timestamp and third line for the actual command),
    so if the numbers of the commands exceeds 50, the first command (The oldest) in the file will be deleted

    below is an example of one command entry in the history file

    # 2022-03-04 09:37:13.350959
    +compute instance launch

    :param filename:
    :return:
    r   r+   Tw   N)open	readlines
startswith"INTERACTIVE_COMMANDS_HISTORY_LIMITread
splitlines
writelines)filenameZcommands_counterfilelineslinedataZ
file_write r   5usr/lib/python3.10/site-packages/interactive/utils.pyvalidate_commands_limitO   s   

"r   c                  C   s   d} t jt jdt}t j|r,t|d}| } W d    n1 s'w   Y  | dkrUtt	 d} t|d}|
t|  W d    d S 1 sNw   Y  d S d S )Nr   r   r
   r   r   )ospath
expanduserjoin	file_nameexistsr   r   printMESSAGEwritestr)valuer   fr   r   r   print_suggestion_messagej   s   
"r*   )os.pathr   ZOCI_CLI_DISABLE_COLORS_ENV_VARr   r!   r    Z%INTERACTIVE_COMMANDS_HISTORY_DIR_NAMEZ&INTERACTIVE_COMMANDS_HISTORY_FILE_NAMEr   ZAUTHENTICATION_PARAMSZDEBUG_PARAMSZAUTO_PROMPT_PARAMSZANONYMOUS_PARAMSZparameters_to_excludeZstyles_dictZparameter_resource_mappingZREQUIRED_PARAM_EXCEPTIONr%   r"   r   r*   r   r   r   r   <module>   sX   	