Skip to content

Instantly share code, notes, and snippets.

@prednaz
Created March 5, 2024 11:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prednaz/9efc6f3fa4bf6ab04a9c6afbbc6847f6 to your computer and use it in GitHub Desktop.
Save prednaz/9efc6f3fa4bf6ab04a9c6afbbc6847f6 to your computer and use it in GitHub Desktop.
{- cabal:
default-language: GHC2021
default-extensions:
NoImplicitPrelude
NoFieldSelectors
LambdaCase
ghc-options:
-Weverything
-Wno-unsafe
-Wno-missing-safe-haskell-mode
-Wno-missing-import-lists
-Wno-unused-imports
-Werror
build-depends:
, relude ==1.2.1.0
, safe-exceptions ==0.1.7.4
, typed-process ==0.2.11.1
, directory ==1.3.7.1
, unix ==2.7.3
-}
{- project:
with-compiler: ghc-9.4.8
optimization: 0
-}
import Control.Exception.Safe (throwString)
import System.Process.Typed (runProcess, setWorkingDir, shell)
import System.Directory (listDirectory)
import System.Posix.Files (getFileStatus, isDirectory)
import Relude
paths :: IO [FilePath]
paths =
filterM ((fmap . fmap) isDirectory getFileStatus) =<< listDirectory "."
main :: IO ()
main =
do
command <-
getArgs
>>= \case
[p] -> pure p
_ -> throwString "Please provide one command argument."
traverse_
(\path ->
putStrLn path *>
(runProcess $ setWorkingDir path $ shell $ command) *>
putStrLn ""
)
=<< paths
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment