simple-cmd 0.2.5 → 0.2.6
raw patch · 4 files changed
+23/−7 lines, 4 files
Files
- ChangeLog.md +3/−0
- README.md +1/−0
- simple-cmd.cabal +4/−5
- src/SimpleCmd.hs +15/−2
ChangeLog.md view
@@ -1,5 +1,8 @@ # Version history for simple-cmd +## 0.2.6 (2022-05-18)+- timeIO: print the duration in hours and minutes, not just seconds+ ## 0.2.5 (2022-04-24) - cmdN: quote arguments with show - add timeIO: runs action and prints the time it took
README.md view
@@ -46,6 +46,7 @@ gitBranch :: IO String grep_ pat file :: IO Bool sudo_ c args :: IO ()+timeIO :: IO a -> IO a ``` See the library documentation for more details.
simple-cmd.cabal view
@@ -1,12 +1,12 @@ name: simple-cmd-version: 0.2.5+version: 0.2.6 synopsis: Simple String-based process commands description: Simple wrappers over System.Process (readProcess, readProcessWithExitCode, rawSystem, and createProcess). The idea is to provide some common idioms for calling out to commands from programs. For more advanced shell-scripting or streaming- use turtle, shelly, command, etc.+ use turtle, shelly, shake, etc. license: BSD3 license-file: LICENSE author: Jens Petersen <juhpetersen@gmail.com>@@ -18,9 +18,8 @@ build-type: Simple cabal-version: >=1.10 extra-source-files: README.md ChangeLog.md TODO-tested-with: GHC == 7.4.2, GHC == 7.6.3, GHC == 7.8.4, GHC == 7.10.3,- GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.4, GHC == 8.6.5,- GHC == 8.8.4, GHC == 8.10.7, GHC == 9.0.2+tested-with: GHC == 7.10.3, GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.4,+ GHC == 8.6.5, GHC == 8.8.4, GHC == 8.10.7, GHC == 9.0.2 source-repository head type: git
src/SimpleCmd.hs view
@@ -77,7 +77,9 @@ stripPrefix) import Data.Maybe (isJust, isNothing, fromMaybe) import Data.Time.Clock-+#if MIN_VERSION_time(1,9,0)+import Data.Time.Format (formatTime, defaultTimeLocale)+#endif import System.Directory (findExecutable, listDirectory) import System.Exit (ExitCode (..)) import System.FilePath@@ -492,5 +494,16 @@ (\start -> do end <- getCurrentTime let duration = diffUTCTime end start- putStrLn $ "took " ++ show duration)+ putStrLn $ "took " ++ renderDuration duration) (const action)+ where+#if MIN_VERSION_time(1,9,0)+ renderDuration dur =+ let fmtstr+ | dur < 60 = "%s sec"+ | dur < 3600 = "%m min %S sec"+ | otherwise = "%h hours %M min"+ in formatTime defaultTimeLocale fmtstr dur+#else+ renderDuration = show+#endif