mirror of https://github.com/voidlizard/hbs2
bf6: suckless-script call:proc:raw
This commit is contained in:
parent
f2f38c5ca9
commit
80f503c873
|
@ -50,6 +50,30 @@ callProc name params syn = do
|
||||||
parseTop s & either (liftIO . throwIO) pure
|
parseTop s & either (liftIO . throwIO) pure
|
||||||
|
|
||||||
|
|
||||||
|
-- FIXME: to-suckless-script
|
||||||
|
callProcRaw :: forall m . MonadIO m
|
||||||
|
=> FilePath
|
||||||
|
-> [String]
|
||||||
|
-> m Text
|
||||||
|
|
||||||
|
callProcRaw name params = do
|
||||||
|
-- let input = fmap (LBS.fromStrict . TE.encodeUtf8 . T.pack . show . pretty) syn
|
||||||
|
-- & LBS8.unlines
|
||||||
|
-- & byteStringInput
|
||||||
|
|
||||||
|
-- let what = proc name params & setStderr closed & setStdin input
|
||||||
|
let what = proc name params & setStderr closed & setStdin closed
|
||||||
|
(code, i, o) <- readProcess what
|
||||||
|
|
||||||
|
unless (code == ExitSuccess) do
|
||||||
|
liftIO $ hPrint stderr ( pretty $ LBS8.unpack o )
|
||||||
|
liftIO $ throwIO (CallProcException code)
|
||||||
|
|
||||||
|
let s = TE.decodeUtf8With TE.lenientDecode (LBS.toStrict i)
|
||||||
|
|
||||||
|
pure s
|
||||||
|
|
||||||
|
|
||||||
pipeProcText :: forall m . MonadIO m
|
pipeProcText :: forall m . MonadIO m
|
||||||
=> FilePath
|
=> FilePath
|
||||||
-> [String]
|
-> [String]
|
||||||
|
|
|
@ -1634,6 +1634,17 @@ internalEntries = do
|
||||||
_ -> throwIO (BadFormException @c nil)
|
_ -> throwIO (BadFormException @c nil)
|
||||||
|
|
||||||
|
|
||||||
|
brief "calls external process"
|
||||||
|
$ entry $ bindMatch "call:proc:raw" \case
|
||||||
|
[StringLike what] -> lift do
|
||||||
|
callProcRaw what mempty <&> mkStr @c
|
||||||
|
|
||||||
|
(StringLike x:xs) -> lift do
|
||||||
|
callProcRaw x (fmap (show.pretty) xs) <&> mkStr @c
|
||||||
|
|
||||||
|
_ -> throwIO (BadFormException @c nil)
|
||||||
|
|
||||||
|
|
||||||
brief "call external process as pipe"
|
brief "call external process as pipe"
|
||||||
$ entry $ bindMatch "proc:pipe" \case
|
$ entry $ bindMatch "proc:pipe" \case
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue