wip, suckless-conf script

This commit is contained in:
voidlizard 2024-10-20 08:11:29 +03:00
parent 2ef87e22b8
commit 0de201a0d8
1 changed files with 30 additions and 9 deletions

View File

@ -981,7 +981,7 @@ internalEntries = do
[ sy ] -> display sy >> liftIO (putStrLn "") [ sy ] -> display sy >> liftIO (putStrLn "")
ss -> mapM_ display ss >> liftIO (putStrLn "") ss -> mapM_ display ss >> liftIO (putStrLn "")
entry $ bindMatch "str:read-stdin" $ \case entry $ bindMatch "str:stdin" $ \case
[] -> liftIO getContents <&> mkStr @c [] -> liftIO getContents <&> mkStr @c
_ -> throwIO (BadFormException @c nil) _ -> throwIO (BadFormException @c nil)
@ -991,7 +991,7 @@ internalEntries = do
_ -> throwIO (BadFormException @c nil) _ -> throwIO (BadFormException @c nil)
brief "reads file as a string" do brief "reads file as a string" do
entry $ bindMatch "str:read-file" $ \case entry $ bindMatch "str:file" $ \case
[StringLike fn] -> liftIO (TIO.readFile fn) <&> mkStr [StringLike fn] -> liftIO (TIO.readFile fn) <&> mkStr
_ -> throwIO (BadFormException @c nil) _ -> throwIO (BadFormException @c nil)
@ -1158,19 +1158,40 @@ internalEntries = do
brief "reads bytes from a file" brief "reads bytes from a file"
$ desc "bytes:read:file FILE" $ desc "bytes:file FILE"
$ entry $ bindMatch "bytes:read:file" $ \case $ entry $ bindMatch "bytes:file" $ \case
[ StringLike fn ] -> do [ StringLike fn ] -> do
liftIO (BS.readFile fn) >>= mkOpaque liftIO (LBS.readFile fn) >>= mkOpaque
_ -> throwIO (BadFormException @c nil) _ -> throwIO (BadFormException @c nil)
brief "reads bytes from a STDIN" brief "reads bytes from a STDIN"
$ desc "bytes:read:stdin" $ desc "bytes:stdin"
$ entry $ bindMatch "bytes:read:stdin" $ \case $ entry $ bindMatch "bytes:stdin" $ \case
[] -> do [] -> do
liftIO BS.getContents >>= mkOpaque liftIO LBS.getContents >>= mkOpaque
_ -> throwIO (BadFormException @c nil)
brief "writes bytes to STDOUT"
$ desc "bytes:put <BYTES>"
$ entry $ bindMatch "bytes:put" $ nil_ $ \case
[isOpaqueOf @LBS.ByteString -> Just s ] -> do
liftIO $ LBS.putStr s
[isOpaqueOf @ByteString -> Just s ] -> do
liftIO $ BS.putStr s
_ -> throwIO (BadFormException @c nil)
brief "writes bytes to FILE"
$ desc "bytes:write <FILE> <BYTES>"
$ entry $ bindMatch "bytes:write" $ nil_ $ \case
[StringLike fn, isOpaqueOf @LBS.ByteString -> Just s ] -> do
liftIO $ LBS.writeFile fn s
[StringLike fn, isOpaqueOf @ByteString -> Just s ] -> do
liftIO $ BS.writeFile fn s
_ -> throwIO (BadFormException @c nil) _ -> throwIO (BadFormException @c nil)