--bare option to init #515

This commit is contained in:
Michael Snoyman 2013-09-08 17:17:05 +02:00
parent 5b379067b2
commit 94e4310a9c
2 changed files with 8 additions and 6 deletions

View File

@ -67,8 +67,9 @@ validPN c
validPN '-' = True
validPN _ = False
scaffold :: IO ()
scaffold = do
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"
@ -90,7 +91,7 @@ scaffold = do
putStrLn "That's it! I'm creating your files now..."
let sink = unpackTemplate
(receiveFS $ fromString project)
(receiveFS $ if isBare then "." else fromString project)
(T.replace "PROJECTNAME" (T.pack project))
case ebackend of
Left req -> withManager $ \m -> do

View File

@ -42,7 +42,7 @@ data Options = Options
}
deriving (Show, Eq)
data Command = Init
data Command = Init { _initBare :: Bool }
| Configure
| Build { buildExtraArgs :: [String] }
| Touch
@ -89,7 +89,7 @@ main = do
] optParser'
let cabal xs = rawSystem' (cabalCommand o) xs
case optCommand o of
Init -> scaffold
Init bare -> scaffold bare
Configure -> cabal ["configure"]
Build es -> touch' >> cabal ("build":es)
Touch -> touch'
@ -109,7 +109,8 @@ optParser :: Parser Options
optParser = Options
<$> flag Cabal CabalDev ( long "dev" <> short 'd' <> help "use cabal-dev" )
<*> switch ( long "verbose" <> short 'v' <> help "More verbose output" )
<*> subparser ( command "init" (info (pure Init)
<*> subparser ( command "init"
(info (Init <$> (switch (long "bare" <> help "Create files in current folder")))
(progDesc "Scaffold a new site"))
<> command "configure" (info (pure Configure)
(progDesc "Configure a project for building"))