Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

usage message

  • Loading branch information...
commit f002bfc0e3899e0e13242757d56c6f59db38e489 1 parent 4a3404d
@singpolyma authored
Showing with 16 additions and 11 deletions.
  1. +16 −11 routeGenerator.hs
View
27 routeGenerator.hs
@@ -1,6 +1,7 @@
module Main where
import System.Environment (getArgs)
+import System.IO (hPutStrLn, stderr)
import Data.List (intercalate)
import Data.Char (isUpper, isSpace)
import Data.Maybe (catMaybes, isJust)
@@ -92,15 +93,19 @@ parser = many1 $ do
main :: IO ()
main = do
- [input, mod] <- getArgs
- Right routes <- fmap (parseOnly parser) $ T.readFile input
+ args <- getArgs
+ case args of
+ [input, mod] -> do
+ Right routes <- fmap (parseOnly parser) $ T.readFile input
- putStrLn "module Routes where"
- putStrLn ""
- putStrLn $ "import " ++ mod
- putStrLn "import Control.Monad (ap)"
- putStrLn "import Data.Text (pack)"
- putStrLn "import Web.PathPieces (fromPathPiece)"
- putStrLn "import Yesod.Routes.Dispatch (Route(..), Piece(Static, Dynamic))"
- putStrLn ""
- emitRoutes routes
+ putStrLn "module Routes where"
+ putStrLn ""
+ putStrLn $ "import " ++ mod
+ putStrLn "import Control.Monad (ap)"
+ putStrLn "import Data.Text (pack)"
+ putStrLn "import Web.PathPieces (fromPathPiece)"
+ putStrLn "import Yesod.Routes.Dispatch (Route(..), Piece(Static, Dynamic))"
+ putStrLn ""
+ emitRoutes routes
+ _ ->
+ hPutStrLn stderr "Usage: ./routeGenerator <input file> <implementation module>"
Please sign in to comment.
Something went wrong with that request. Please try again.