From 94e4310a9c6ee2e38e14140b0603758a52fa45e8 Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Sun, 8 Sep 2013 17:17:05 +0200 Subject: [PATCH] --bare option to init #515 --- yesod-bin/Scaffolding/Scaffolder.hs | 7 ++++--- yesod-bin/main.hs | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/yesod-bin/Scaffolding/Scaffolder.hs b/yesod-bin/Scaffolding/Scaffolder.hs index bd055d87..ac015295 100644 --- a/yesod-bin/Scaffolding/Scaffolder.hs +++ b/yesod-bin/Scaffolding/Scaffolder.hs @@ -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 diff --git a/yesod-bin/main.hs b/yesod-bin/main.hs index 11d6ead3..3c5ff739 100755 --- a/yesod-bin/main.hs +++ b/yesod-bin/main.hs @@ -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"))