#Include "trucha_tools.au3"
if ($CmdLine[0]<4) then
   msgbox(0,"","Usage: "&@scriptname&" trucha.exe_path iso_path [extract|replace] data_path [songname]")
   exit
EndIf

$trucha = $CmdLine[1]
$isofile = $CmdLine[2]
$action = $CmdLine[3]
$path = $CmdLine[4]
$partition = "PARTITION (RGHE52)"
$gui = "Trucha Signer 0.21"
$treeview = "SysTreeView321"

if (($action<>"extract1")  and ($action<>"extract3") and  ($action<>"replace1") and  ($action<>"replace3") and ($action<>"extractAll") and ($action<>"replaceAll")) then
   MsgBox(0,"","Action must be one of: extract1 extract3 replace1 replace3")
   exit
EndIf

if ((($action=="extract1")  or ($action=="extract3") or ($action=="replace1") or ($action=="replace3")) and ($CmdLine[0]<>5)) then
   msgbox(0,"","Usage: "&@scriptname&" trucha.exe_path iso_path [extract|replace] data_path [songname]")
   exit
elseif (($action=="extract1")  or ($action=="extract3") or ($action=="replace1") or ($action=="replace3")) then
   $file = $CmdLine[5]
EndIf


_Trucha_init( $trucha, $gui, $isofile)
$hWnd = ControlGetHandle( $gui, "", $treeview )

Select 
   Case $action=="extract1"
      _Extract_File($file,$path,$hWnd)
   Case $action=="replace1"
      _Replace_File($file,$path,$hWnd)
      _Sign_Partition($partition,$hWnd)      
   Case $action=="extract3"
      _Extract3($file,$path,$hWnd)
   Case $action=="replace3"
      _Replace3($file,$path,$hWnd)
      _Sign_Partition($partition,$hWnd)
   Case $action=="extractAll"
      _Extract_All($path,$hWnd)
   Case $action=="replaceAll"
      _Replace_All($path,$hWnd)
      _Sign_Partition($partition,$hWnd)
   Case Else
      msgbox(0,"","Unkown action")
EndSelect


WinClose($gui)
Sleep(1000)
Exit