module Azubi.Module.Runable where
import Azubi.Core.Model
run :: RunCommand -> State
run (Once command arguments result) =
  let
    fullCommand = unwords $ command : arguments
    fileContent = [ "This is a Azubi cache file"
                  , "You can delete or edit it to make the following command run again"
                  , ""
                  , fullCommand ]
  in
    State
    [ HasFileContent result fileContent ]
    [ Run command arguments $ Just $ unwords $ [ "run command" , command ] ++ arguments
    , FileContent result fileContent ]
    (Just $ "run once " ++ command ++ " " ++ (show arguments))
run (Always command arguments) =
  State
  [ Not AlwaysYes ]
  [ Run command arguments $ Just $ unwords $ [ "run command",   command ] ++ arguments ]
  (Just $ "run always " ++ command ++ " " ++ (show arguments))
data RunCommand =
  
  Always String [Argument]
  
  | Once String [Argument] Path