In yesod init, ensure words have atleast one character; fixes #550

This commit is contained in:
Maximilian Tagher 2014-06-06 12:51:00 -07:00
parent d42ba4d024
commit 62877cbba0

View File

@ -15,6 +15,8 @@ import Text.ProjectTemplate (unpackTemplate, receiveFS)
import System.IO
import Text.Shakespeare.Text (renderTextUrl, textFile)
import Network.HTTP.Conduit (withManager, http, parseUrl, responseBody)
import Data.List.Split (splitOn)
import Data.Char (isDigit)
prompt :: (String -> Maybe a) -> IO a
prompt f = do
@ -68,12 +70,14 @@ validPN c
validPN '-' = True
validPN _ = False
scaffold :: Bool -- ^ bare directory instead of a new subdirectory?
-> IO ()
scaffold isBare = do
puts $ renderTextUrl undefined $(textFile "input/welcome.cg")
project <- prompt $ \s ->
if all validPN s && not (null s) && s /= "test"
if all validPN s && not (null s) && s /= "test" && (not $ any (all isDigit) (splitOn "-" s))
then Just s
else Nothing
let dir = project