# simple-cmd-args
[](https://hackage.haskell.org/package/simple-cmd-args)
[](LICENSE)
[](http://stackage.org/lts/package/simple-cmd-args)
[](http://stackage.org/nightly/package/simple-cmd-args)
[](https://travis-ci.org/juhp/simple-cmd-args)
A thin layer over optparse-applicative that avoids type plumbing for
subcommands by using `Parser (IO ())`.
## Usage
```haskell
import SimpleCmdArgs
import Control.Applicative (some)
import System.Directory
main =
simpleCmdArgs Nothing "example-tool" "Longer description..." $
subcommands
[ Subcommand "echo" "Print words" $
putStrLn . unwords <$> some (strArg "STR...")
, Subcommand "ls" "List directory" $
ls <$> strArg "DIR"
, Subcommand "mkdir" "Create directory" $
mkdir <$> parentsOpt <*> strArg "DIR"
]
where
parentsOpt = switchWith 'p' "parents" "Make missing directories"
ls :: FilePath -> IO ()
ls dir =
listDirectory dir >>= mapM_ putStrLn
mkdir :: Bool -> FilePath -> IO ()
mkdir parents =
if parents then createDirectoryIfMissing True else createDirectory
```
See more [examples](https://github.com/juhp/simple-cmd-args/tree/master/examples).