Permalink
Browse files

Add --version support

  • Loading branch information...
bneijt committed Aug 11, 2014
1 parent c62798f commit 22cb0c4bbf843f9f4e22dca0c2f3e8e747e97b3a
Showing with 9 additions and 6 deletions.
  1. +1 −1 after.cabal
  2. +8 −5 src/Main.hs
@@ -1,5 +1,5 @@
name: after
version: 0.1.1.0
version: 0.1.2.0
description: Command line utility to wait for process termination
homepage: http://bneijt.nl
license: GPL-3
@@ -2,21 +2,24 @@ import Control.Applicative
import Options
import Control.Concurrent.ParallelIO.Global (parallel_, stopGlobalPool)

import Paths_after (version)
import Data.Version (showVersion)

import After (afterPartialCmdline)

data MainOptions = MainOptions
{ optQuiet :: Bool
{ optVersion :: Bool
}

instance Options MainOptions where
defineOptions = pure MainOptions
<*> simpleOption "quiet" False
"Whether to be quiet."
<*> simpleOption "version" False
"Show the program version"

main :: IO ()
main = runCommand $ \opts args -> do
if optQuiet opts
then return ()
if optVersion opts
then putStrLn ("after " ++ showVersion version)
else do
parallel_ (map afterPartialCmdline args)
stopGlobalPool

0 comments on commit 22cb0c4

Please sign in to comment.