{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TypeFamilies #-}
module Cuk.Shell
( ($|)
) where
import System.Process (callCommand, readProcess, showCommandForUser)
import qualified Data.Text as T
instance (a ~ Text, b ~ ()) => IsString ([a] -> IO b) where
fromString :: String -> [Text] -> IO ()
fromString cmd args = do
let cmdStr = showCommandForUser cmd (map toString args)
putStrLn $ "⚙ " ++ cmdStr
callCommand cmdStr
infix 5 $|
($|) :: FilePath -> [Text] -> IO Text
cmd $| args = T.strip . toText <$> readProcess cmd (map toString args) ""