hunk ./Distribution/Client/Init/Licenses.hs 15 - [ "Copyright (c)" ++ year ++ ", " ++ authors + [ "Copyright (c) " ++ year ++ ", " ++ authors hunk ./Distribution/Client/Init.hs 406 - vcat [ fieldS "Name" (packageName c) + vcat [ fieldS "name" (packageName c) hunk ./Distribution/Client/Init.hs 410 - , field "Version" (version c) + , field "version" (version c) hunk ./Distribution/Client/Init.hs 414 - , fieldS "Synopsis" (synopsis c) + , fieldS "synopsis" (synopsis c) hunk ./Distribution/Client/Init.hs 418 - , fieldS "Description" NoFlag + , fieldS "description" NoFlag hunk ./Distribution/Client/Init.hs 422 - , fieldS "Homepage" (homepage c) + , fieldS "homepage" (homepage c) hunk ./Distribution/Client/Init.hs 426 - , fieldS "Bug-reports" NoFlag + , fieldS "bug-reports" NoFlag hunk ./Distribution/Client/Init.hs 430 - , field "License" (license c) + , field "license" (license c) hunk ./Distribution/Client/Init.hs 434 - , fieldS "License-file" (Flag "LICENSE") + , fieldS "license-file" (Flag "LICENSE") hunk ./Distribution/Client/Init.hs 438 - , fieldS "Author" (author c) + , fieldS "author" (author c) hunk ./Distribution/Client/Init.hs 442 - , fieldS "Maintainer" (email c) + , fieldS "maintainer" (email c) hunk ./Distribution/Client/Init.hs 446 - , fieldS "Copyright" NoFlag + , fieldS "copyright" NoFlag hunk ./Distribution/Client/Init.hs 450 - , fieldS "Category" (either id display `fmap` category c) + , fieldS "category" (either id display `fmap` category c) hunk ./Distribution/Client/Init.hs 454 - , fieldS "Build-type" (Flag "Simple") + , fieldS "build-type" (Flag "Simple") hunk ./Distribution/Client/Init.hs 458 - , fieldS "Extra-source-files" NoFlag + , fieldS "extra-source-files" NoFlag hunk ./Distribution/Client/Init.hs 462 - , field "Cabal-version" (Flag $ orLaterVersion (Version [1,2] [])) + , field "cabal-version" (Flag $ orLaterVersion (Version [1,2] [])) hunk ./Distribution/Client/Init.hs 468 - text "\nExecutable" <+> text (fromMaybe "" . flagToMaybe $ packageName c) $$ (nest 2 $ vcat - [ fieldS "Main-is" NoFlag (Just ".hs or .lhs file containing the Main module.") True + text "\nexecutable" <+> text (fromMaybe "" . flagToMaybe $ packageName c) $$ (nest 2 $ vcat + [ fieldS "main-is" NoFlag (Just ".hs or .lhs file containing the Main module.") True hunk ./Distribution/Client/Init.hs 473 - Flag Library -> text "\nLibrary" $$ (nest 2 $ vcat - [ fieldS "Exposed-modules" (listField (exposedModules c)) + Flag Library -> text "\nlibrary" $$ (nest 2 $ vcat + [ fieldS "exposed-modules" (listField (exposedModules c)) hunk ./Distribution/Client/Init.hs 485 - [ fieldS "Build-depends" (listField (dependencies c')) + [ fieldS "build-depends" (listField (dependencies c')) hunk ./Distribution/Client/Init.hs 489 - , fieldS "Other-modules" (listField (otherModules c')) + , fieldS "other-modules" (listField (otherModules c')) hunk ./Distribution/Client/Init.hs 497 - , fieldS "Build-tools" (listFieldS (buildTools c')) + , fieldS "build-tools" (listFieldS (buildTools c')) hunk ./Distribution/Client/Init.hs 97 + >=> getGenComments hunk ./Distribution/Client/Init.hs 210 +-- | Ask whether to generate explanitory comments. +getGenComments :: InitFlags -> IO InitFlags +getGenComments flags = do + genComments <- return (flagToMaybe $ noComments flags) + ?>> maybePrompt flags (promptYesNo "Include documentation on what each field means y/n" (Just False)) + ?>> return (Just False) + return $ flags { noComments = maybeToFlag (fmap not genComments) } + hunk ./Distribution/Client/Init.hs 266 +-- | Create a yes/no prompt with optional default value. +-- +promptYesNo :: String -> Maybe Bool -> IO Bool +promptYesNo = + promptDefault' recogniseYesNo showYesNo + where + recogniseYesNo s | s == "y" || s == "Y" = Just True + | s == "n" || s == "N" = Just False + | otherwise = Nothing + showYesNo True = "y" + showYesNo False = "n" + hunk ./Distribution/Client/Init.hs 304 -mkDefPrompt pr def = pr ++ defStr def ++ "? " - where defStr Nothing = "" - defStr (Just s) = " [default \"" ++ s ++ "\"]" +mkDefPrompt pr def = pr ++ "?" ++ defStr def + where defStr Nothing = " " + defStr (Just s) = " [default \"" ++ s ++ "\"] " hunk ./Distribution/Client/Init.hs 422 -generateCabalFile fileName c = render $ +generateCabalFile fileName c = + renderStyle style { lineLength = 79, ribbonsPerLine = 1.1 } $ hunk ./Distribution/Client/Init.hs 425 - then showComment (Just $ fileName ++ " auto-generated by cabal init. For additional options, see http://www.haskell.org/cabal/release/cabal-latest/doc/users-guide/authors.html#pkg-descr.") + then showComment (Just $ "Initial " ++ fileName ++ " generated by cabal " + ++ "init. For further documentation, see " + ++ "http://haskell.org/cabal/users-guide/") + $$ text "" hunk ./Distribution/Client/Init.hs 559 - . render . fsep . map text . words $ t + . renderStyle style { + lineLength = 76, + ribbonsPerLine = 1.05 + } + . fsep . map text . words $ t hunk ./Distribution/Client/Init.hs 32 - ( intersperse ) + ( intersperse, (\\) ) hunk ./Distribution/Client/Init.hs 41 - ( (>=>) ) + ( (>=>), join ) hunk ./Distribution/Client/Init.hs 142 - ?>> fmap (fmap (either UnknownLicense id)) + ?>> fmap (fmap (either UnknownLicense id) . join) hunk ./Distribution/Client/Init.hs 144 - (promptList "Please choose a license" - knownLicenses (Just BSD3) True)) + (promptListOptional "Please choose a license" listedLicenses)) hunk ./Distribution/Client/Init.hs 146 + where + listedLicenses = + knownLicenses \\ [GPL Nothing, LGPL Nothing, OtherLicense] hunk ./Distribution/Client/Init.hs 196 - ?>> maybePrompt flags (promptList "Project category" [Codec ..] - Nothing True) + ?>> fmap join (maybePrompt flags + (promptListOptional "Project category" [Codec ..])) hunk ./Distribution/Client/Init.hs 207 - Nothing False)) + Nothing display False)) hunk ./Distribution/Client/Init.hs 216 - ?>> maybePrompt flags (promptYesNo "Include documentation on what each field means y/n" (Just False)) + ?>> maybePrompt flags (promptYesNo promptMsg (Just False)) hunk ./Distribution/Client/Init.hs 219 + where + promptMsg = "Include documentation on what each field means y/n" hunk ./Distribution/Client/Init.hs 310 - defStr (Just s) = " [default \"" ++ s ++ "\"] " + defStr (Just s) = " [default: " ++ s ++ "] " + +promptListOptional :: (Text t, Eq t) + => String -- ^ prompt + -> [t] -- ^ choices + -> IO (Maybe (Either String t)) +promptListOptional pr choices = + fmap rearrange + $ promptList pr (Nothing : map Just choices) (Just Nothing) + (maybe "(none)" display) True + where + rearrange = either (Just . Left) (maybe Nothing (Just . Right)) hunk ./Distribution/Client/Init.hs 324 -promptList :: (Text t, Eq t) +promptList :: Eq t hunk ./Distribution/Client/Init.hs 328 + -> (t -> String) -- ^ show an item hunk ./Distribution/Client/Init.hs 331 -promptList pr choices def other = do +promptList pr choices def displayItem other = do hunk ./Distribution/Client/Init.hs 333 - let options1 = map (\c -> (Just c == def, display c)) choices + let options1 = map (\c -> (Just c == def, displayItem c)) choices hunk ./Distribution/Client/Init.hs 338 - promptList' (length options2) choices def other + promptList' displayItem (length options2) choices def other hunk ./Distribution/Client/Init.hs 345 -promptList' :: Text t => Int -> [t] -> Maybe t -> Bool -> IO (Either String t) -promptList' numChoices choices def other = do - putStr $ mkDefPrompt "Your choice" (display `fmap` def) +promptList' :: (t -> String) -> Int -> [t] -> Maybe t -> Bool -> IO (Either String t) +promptList' displayItem numChoices choices def other = do + putStr $ mkDefPrompt "Your choice" (displayItem `fmap` def) hunk ./Distribution/Client/Init.hs 355 - promptList' numChoices choices def other + promptList' displayItem numChoices choices def other hunk ./Distribution/Client/Init.hs 501 - True + False hunk ./Distribution/Client/Init.hs 503 - , field "cabal-version" (Flag $ orLaterVersion (Version [1,2] [])) + , field "cabal-version" (Flag $ orLaterVersion (Version [1,8] [])) hunk ./Distribution/Client/Init.hs 512 - , generateBuildInfo c + , generateBuildInfo Executable c hunk ./Distribution/Client/Init.hs 519 - , generateBuildInfo c + , generateBuildInfo Library c hunk ./Distribution/Client/Init.hs 524 - generateBuildInfo :: InitFlags -> Doc - generateBuildInfo c' = vcat - [ fieldS "build-depends" (listField (dependencies c')) - (Just "Packages needed in order to build this package.") + generateBuildInfo :: PackageType -> InitFlags -> Doc + generateBuildInfo pkgtype c' = vcat + [ fieldS "other-modules" (listField (otherModules c')) + (Just $ case pkgtype of + Library -> "Modules included in this library but not exported." + Executable -> "Modules included in this executable, other than Main.") hunk ./Distribution/Client/Init.hs 532 - , fieldS "other-modules" (listField (otherModules c')) - (Just "Modules not exported by this package.") + , fieldS "build-depends" (listField (dependencies c')) + (Just "Other library packages from which modules are imported.") hunk ./Distribution/Client/Init.hs 537 - (Just "Directories other than the root containing source files.") + (Just "Directories containing source files.") hunk ./Distribution/Client/Init.hs 542 - True + False