--bare option to init #515
This commit is contained in:
parent
5b379067b2
commit
94e4310a9c
@ -67,8 +67,9 @@ validPN c
|
|||||||
validPN '-' = True
|
validPN '-' = True
|
||||||
validPN _ = False
|
validPN _ = False
|
||||||
|
|
||||||
scaffold :: IO ()
|
scaffold :: Bool -- ^ bare directory instead of a new subdirectory?
|
||||||
scaffold = do
|
-> IO ()
|
||||||
|
scaffold isBare = do
|
||||||
puts $ renderTextUrl undefined $(textFile "input/welcome.cg")
|
puts $ renderTextUrl undefined $(textFile "input/welcome.cg")
|
||||||
project <- prompt $ \s ->
|
project <- prompt $ \s ->
|
||||||
if all validPN s && not (null s) && s /= "test"
|
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..."
|
putStrLn "That's it! I'm creating your files now..."
|
||||||
|
|
||||||
let sink = unpackTemplate
|
let sink = unpackTemplate
|
||||||
(receiveFS $ fromString project)
|
(receiveFS $ if isBare then "." else fromString project)
|
||||||
(T.replace "PROJECTNAME" (T.pack project))
|
(T.replace "PROJECTNAME" (T.pack project))
|
||||||
case ebackend of
|
case ebackend of
|
||||||
Left req -> withManager $ \m -> do
|
Left req -> withManager $ \m -> do
|
||||||
|
|||||||
@ -42,7 +42,7 @@ data Options = Options
|
|||||||
}
|
}
|
||||||
deriving (Show, Eq)
|
deriving (Show, Eq)
|
||||||
|
|
||||||
data Command = Init
|
data Command = Init { _initBare :: Bool }
|
||||||
| Configure
|
| Configure
|
||||||
| Build { buildExtraArgs :: [String] }
|
| Build { buildExtraArgs :: [String] }
|
||||||
| Touch
|
| Touch
|
||||||
@ -89,7 +89,7 @@ main = do
|
|||||||
] optParser'
|
] optParser'
|
||||||
let cabal xs = rawSystem' (cabalCommand o) xs
|
let cabal xs = rawSystem' (cabalCommand o) xs
|
||||||
case optCommand o of
|
case optCommand o of
|
||||||
Init -> scaffold
|
Init bare -> scaffold bare
|
||||||
Configure -> cabal ["configure"]
|
Configure -> cabal ["configure"]
|
||||||
Build es -> touch' >> cabal ("build":es)
|
Build es -> touch' >> cabal ("build":es)
|
||||||
Touch -> touch'
|
Touch -> touch'
|
||||||
@ -109,7 +109,8 @@ optParser :: Parser Options
|
|||||||
optParser = Options
|
optParser = Options
|
||||||
<$> flag Cabal CabalDev ( long "dev" <> short 'd' <> help "use cabal-dev" )
|
<$> flag Cabal CabalDev ( long "dev" <> short 'd' <> help "use cabal-dev" )
|
||||||
<*> switch ( long "verbose" <> short 'v' <> help "More verbose output" )
|
<*> 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"))
|
(progDesc "Scaffold a new site"))
|
||||||
<> command "configure" (info (pure Configure)
|
<> command "configure" (info (pure Configure)
|
||||||
(progDesc "Configure a project for building"))
|
(progDesc "Configure a project for building"))
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user