diff options
author | Fabian Kirchner <kirchner@posteo.de> | 2023-10-13 21:24:04 +0200 |
---|---|---|
committer | Fabian Kirchner <kirchner@posteo.de> | 2023-10-13 22:19:24 +0200 |
commit | a0c72a80fbfed8e0963edff17ab5d52d2e3abd5b (patch) | |
tree | ad33fffa970f94d8931e70644e44946cc3dfe524 /app/Main.hs | |
parent | 09d5a5941a1feb23aece4d5311092c1a23d4ae11 (diff) |
refactor: extract sh and sh_ into Process
Diffstat (limited to 'app/Main.hs')
-rw-r--r-- | app/Main.hs | 23 |
1 files changed, 2 insertions, 21 deletions
diff --git a/app/Main.hs b/app/Main.hs index 9e25025..bfe634c 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -72,9 +72,8 @@ module Main where -import Control.Exception (Exception, catch, handle, throw, throwIO) +import Control.Exception (Exception, catch, handle, throw) import Data.Aeson qualified as A -import Data.ByteString.Lazy qualified as L import Data.ByteString.Lazy.Char8 qualified as L8 import Data.List (find, intercalate) import Data.Maybe (catMaybes, fromMaybe) @@ -89,6 +88,7 @@ import Options.Applicative ((<**>)) import Options.Applicative qualified as O import Prettyprinter qualified as P import Prettyprinter.Render.Terminal qualified as P +import Process (sh, sh_) import System.Exit (ExitCode (ExitFailure), exitWith) import System.FilePath qualified as F import System.Process.Typed qualified as P @@ -300,25 +300,6 @@ getIssues filename = ) ) -data ProcessException = ProcessException String ExitCode L.ByteString - deriving (Show) - -instance Exception ProcessException - -sh :: P.ProcessConfig stdin stdoutIgnored stderr -> IO L.ByteString -sh proc = do - (exitCode, out, err) <- P.readProcess proc - if exitCode == P.ExitSuccess - then pure out - else throwIO $ ProcessException (show proc) exitCode err - -sh_ :: P.ProcessConfig stdin stdoutIgnored stderr -> IO () -sh_ proc = do - (exitCode, err) <- P.readProcessStderr proc - if exitCode == P.ExitSuccess - then pure () - else throwIO $ ProcessException (show proc) exitCode err - fixTreeGrepper :: G.Result -> G.Result fixTreeGrepper treeGrepperResult = treeGrepperResult {G.matches = G.merge treeGrepperResult.matches} |