packages feed

executor (empty) → 0.0.1

raw patch · 7 files changed

+144/−0 lines, 7 filesdep +asyncdep +basedep +processsetup-changed

Dependencies added: async, base, process

Files

+ ChangeLog.md view
@@ -0,0 +1,5 @@+# Revision history for executor++## 0.0.1  -- 2017-08-19++* First version. Released on an unsuspecting world.
+ Executor.hs view
@@ -0,0 +1,32 @@+module Executor where++import System.Process (callCommand)+import Control.Concurrent.Async (async, wait)++-- | Execute a single shell command+-- | Not much different from callCommand though+-- | for example:+-- | main = do+-- |  execSync "ls"++execSync :: String -> IO()++execSync c = do+  task <- async (callCommand c)+  res <- wait task+  return ()++-- | Execute a list of shell commands in sequence synchronously+-- | for example:+-- | main = do+-- |  execListSync ["ls", "whoami"]++execListSync :: [String] -> IO()++execListSync (c:commands) = do+  execSync c+  if length commands > 0+    then do+      execListSync commands+    else+      return ()
+ LICENSE view
@@ -0,0 +1,21 @@+MIT License++Copyright (c) 2017 Gianluca Guarini++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in all+copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE+SOFTWARE.
+ README.md view
@@ -0,0 +1,41 @@+# executor+Haskell module to execute single or multiple shell commands++[![Build Status][travis-image]][travis-url]+[![MIT License][license-image]][license-url]++# API++## execSync++Execute a single shell command++```hs+import Executor (execSync)++main = do+  -- execute a simple `ls` in the current folder+  execSync "ls"+```++## execListSync++Execute a list of shell commands in sequence synchronously++```hs+import Executor (execListSync)++main = do+  -- execute synchronously the following commands+  execListSync [+      "ls",+      "whoami",+      "echo hello"+    ]+```++[travis-image]:https://img.shields.io/travis/GianlucaGuarini/executor.svg?style=flat-square+[travis-url]:https://travis-ci.org/GianlucaGuarini/executor++[license-image]:http://img.shields.io/badge/license-MIT-000000.svg?style=flat-square+[license-url]:LICENSE
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ executor.cabal view
@@ -0,0 +1,31 @@+name:                executor+version:             0.0.1+description:         Haskell module to execute single or multiple shell commands+synopsis:            Shell helpers+homepage:            https://github.com/GianlucaGuarini/executor+license:             MIT+license-file:        LICENSE+author:              Gianluca Guarini+maintainer:          gianluca.guarini@gmail.com+category:            Distribution+build-type:          Simple+extra-source-files:  ChangeLog.md, README.md++cabal-version:       >=1.10++source-repository head+  type:              git+  location:          https://github.com/GianlucaGuarini/executor++Test-Suite test-executor+  type:              exitcode-stdio-1.0+  main-is:           test.hs+  build-depends:     base >=4.9 && <4.10, process >=1.4 && <1.5, async >=2.1 && <2.2+  default-language:  Haskell2010++library+  exposed-modules:   Executor+  build-depends:     base >=4.9 && <4.10, process >=1.4 && <1.5, async >=2.1 && <2.2+  hs-source-dirs:    ./+  default-language:  Haskell2010+
+ test.hs view
@@ -0,0 +1,12 @@+module Main where+import Executor+import System.Exit (exitSuccess)++main :: IO()+main = do+  execSync "ls"+  execListSync [+      "echo hello",+      "echo world"+    ]+  exitSuccess