
    Mg3                         S SK J r   SrS rS r\ " S5      S 5       r\ " S5      S 5       r\ " S	5      S
 5       r\ " S5      S 5       rg)    )pluginroutinesc                     U R                  [        5      nUc  U R                  [        X!05        gXU'   U R                  [        U5        g)zc
Saves a new routine to memory with a name and a list of instructions.
:return: Nothing to return.
N)get_dataROUTINESadd_dataupdate_data)jarviscommandsnamer   s       =/Users/admin/workspace/ai/Jarvis/jarviscli/plugins/routine.pycreate_routiner      s@    
 x(H4"23!8X.    c                     U R                  [        5      n X!   nU H  nU R	                  U5        M     g! [        [        4 a
  n SnAgSnAff = f)z
Executes a routine saved in memory based on its name. If the routine doesn't exist, returns False.

:return: Whether or not the requested routine exists.
NFT)r   r   	TypeErrorKeyErroreval)r
   r   r   routineecommands         r   execute_routiner      sS     x(H. G 	 x  s   6 AAzcreate routinec                     US:X  a  U R                  S5        g / n U R                  S5        U R                  5       nUS:X  a  OUR                  U5        M;  [        XU5        g )N zYou forgot to give a name.z5Type a command, or press enter to finish the routine.)sayinputappendr   )r
   sr   r   s       r   new_routiner   $   s`    Bw

/0H


JK,,.b=   6Q'r   zcall routinec                 L    [        X5      nU(       d  U R                  S5        g g )Nz0The routine you requested doesn't seem to exist.)r   r   )r
   r   successs      r   call_routiner!   3   s!    f(G

EF r   zlist routinesc                     U R                  [        5      nUR                  5        H  nU R                  [	        U5      5        M     g )N)r   r   keysr   str)r
   r   r   is       r   list_routinesr&   :   s0    x(H]]_

3q6 r   zdelete routinec                     U R                  [        5      nX;   a(  UR                  U5        U R                  [        U5        g U R	                  S5        g )NzInvalid routine name)r   r   popr	   r   )r
   r   r   s      r   delete_routinesr)   A   s=    x(H}Q8X.

)*r   N)r   r   r   r   r   r!   r&   r)    r   r   <module>r+      s     
/  ( ( G G   + +r   