module Azubi.Commands.Run where
import Azubi.Core.Command
import Azubi.Core.Context
import Azubi.Commands.File
run:: (Context a) => String -> Maybe File -> a -> [Command]
run command (Just(File path)) _ = [ IfCommand {
testCommand = BoolCommand $ "-e " ++ path
, thenCommand = []
, elseCommand = [ShellCommand command]
}]
run command (Just(Directory path)) _ = [ IfCommand {
testCommand = BoolCommand $ "-d " ++ path
, thenCommand = []
, elseCommand = [ShellCommand command]
}]
run command (Just (Symlink path target)) _ = [ IfCommand {
testCommand = BoolCommand $ "-L " ++ path
, thenCommand = []
, elseCommand = [ShellCommand command]
}]
run command Nothing _ = [ InfoMsg $ "run " ++ command
, ShellCommand command
]