{-# LANGUAGE CPP #-}
{-# LANGUAGE Rank2Types #-}
module System.Process.Microlens.CreateProcess
(
cmdspec_
, cwd_
, env_
, stdin_
, stdout_
, stderr_
, closefds
, creategroup
, delegatectlc
, newsession
#if MIN_VERSION_process(1, 3, 0)
, detachconsole
, createnewconsole
#endif
#if MIN_VERSION_process(1, 4, 0)
, childgroup
, childuser
#endif
#if MIN_VERSION_process(1, 5, 0)
, useprocessjobs
#endif
, HasStdin(..)
, HasStdout(..)
, HasStderr(..)
) where
import Lens.Micro
import qualified System.IO as H
import System.Posix.Types
import System.Process
cmdspec_ :: Lens' CreateProcess CmdSpec
cmdspec_ = lens cmdspec (\t b -> t { cmdspec = b })
cwd_ :: Lens' CreateProcess (Maybe FilePath)
cwd_ = lens cwd (\t b -> t { cwd = b })
env_ :: Lens' CreateProcess (Maybe [(String, String)])
env_ = lens env (\t b -> t { env = b })
stdin_ :: Lens' CreateProcess StdStream
stdin_ = lens std_in (\t b -> t { std_in = b })
stdout_ :: Lens' CreateProcess StdStream
stdout_ = lens std_out (\t b -> t { std_out = b })
stderr_ :: Lens' CreateProcess StdStream
stderr_ = lens std_err (\t b -> t { std_err = b })
closefds :: Lens' CreateProcess Bool
closefds = lens close_fds (\t b -> t { close_fds = b })
creategroup :: Lens' CreateProcess Bool
creategroup = lens create_group (\t b -> t { create_group = b })
delegatectlc :: Lens' CreateProcess Bool
delegatectlc = lens delegate_ctlc (\t b -> t { delegate_ctlc = b })
newsession :: Lens' CreateProcess Bool
newsession = lens new_session (\t b -> t { new_session = b })
#if MIN_VERSION_process(1, 3, 0)
detachconsole :: Lens' CreateProcess Bool
detachconsole = lens detach_console (\t b -> t { detach_console = b })
createnewconsole :: Lens' CreateProcess Bool
createnewconsole = lens create_new_console (\t b -> t { create_new_console = b })
#endif
#if MIN_VERSION_process(1, 4, 0) && !WINDOWS
childgroup :: Lens' CreateProcess (Maybe CGid)
childgroup = lens child_group (\t b -> t { child_group = b })
childuser :: Lens' CreateProcess (Maybe CUid)
childuser = lens child_user (\t b -> t { child_user = b })
#endif
#if MIN_VERSION_process(1, 5, 0)
useprocessjobs :: Lens' CreateProcess Bool
useprocessjobs = lens use_process_jobs (\t b -> t { use_process_jobs = b })
#endif
class HasStdin a where
_Stdin :: Lens' a StdStream
instance HasStdin StdStream where
_Stdin = id
instance HasStdin CreateProcess where
_Stdin = stdin_
class HasStdout a where
_Stdout :: Lens' a StdStream
instance HasStdout StdStream where
_Stdout = id
instance HasStdout CreateProcess where
_Stdout = stdout_
class HasStderr a where
_Stderr :: Lens' a StdStream
instance HasStderr StdStream where
_Stderr = id
instance HasStderr CreateProcess where
_Stderr = stderr_