From 62a1e4ad06817823ae6998af6b8bf7c6e1a9c558 Mon Sep 17 00:00:00 2001 From: Mikhail Glushenkov <mikhail.glushenkov@gmail.com> Date: Tue, 27 Aug 2019 04:48:46 +0100 Subject: [PATCH] Merge pull request #5902 from m-renaud/mrenaud-non-interactive-default Default to non-interactive init. (cherry picked from commit 690d6c56804c9bd90b0d5cfbc0890d98625b6208) --- cabal-install/Distribution/Client/Config.hs | 2 +- cabal-install/Distribution/Client/Init.hs | 4 ++-- cabal-install/Distribution/Client/Setup.hs | 18 +++++++++--------- cabal-install/changelog | 1 + 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/cabal-install/Distribution/Client/Config.hs b/cabal-install/Distribution/Client/Config.hs index 59ae0ff36a..c3082fe1a8 100644 --- a/cabal-install/Distribution/Client/Config.hs +++ b/cabal-install/Distribution/Client/Config.hs @@ -822,7 +822,7 @@ commentSavedConfig = do globalRemoteRepos = toNubList [defaultRemoteRepo] }, savedInitFlags = mempty { - IT.interactive = toFlag True, + IT.interactive = toFlag False, IT.cabalVersion = toFlag (mkVersion [1,10]), IT.language = toFlag Haskell2010, IT.license = toFlag BSD3, diff --git a/cabal-install/Distribution/Client/Init.hs b/cabal-install/Distribution/Client/Init.hs index 980028c4a1..50e0a42f68 100644 --- a/cabal-install/Distribution/Client/Init.hs +++ b/cabal-install/Distribution/Client/Init.hs @@ -696,8 +696,8 @@ eligibleForTestSuite flags = maybePrompt :: InitFlags -> IO t -> IO (Maybe t) maybePrompt flags p = case interactive flags of - Flag False -> return Nothing - _ -> Just `fmap` p + Flag True -> Just `fmap` p + _ -> return Nothing -- | Create a prompt with optional default value that returns a -- String. diff --git a/cabal-install/Distribution/Client/Setup.hs b/cabal-install/Distribution/Client/Setup.hs index eb5330d3d1..230c42ebd6 100644 --- a/cabal-install/Distribution/Client/Setup.hs +++ b/cabal-install/Distribution/Client/Setup.hs @@ -2230,17 +2230,17 @@ defaultInitFlags = emptyInitFlags { IT.initVerbosity = toFlag normal } initCommand :: CommandUI IT.InitFlags initCommand = CommandUI { commandName = "init", - commandSynopsis = "Create a new .cabal package file (interactively).", + commandSynopsis = "Create a new .cabal package file.", commandDescription = Just $ \_ -> wrapText $ - "Cabalise a project by creating a .cabal, Setup.hs, and " - ++ "optionally a LICENSE file.\n" + "Create a .cabal, Setup.hs, and optionally a LICENSE file.\n" ++ "\n" - ++ "Calling init with no arguments (recommended) uses an " - ++ "interactive mode, which will try to guess as much as " - ++ "possible and prompt you for the rest. Command-line " - ++ "arguments are provided for scripting purposes. " - ++ "If you don't want interactive mode, be sure to pass " - ++ "the -n flag.\n", + ++ "Calling init with no arguments creates an executable, " + ++ "guessing as many options as possible. The interactive " + ++ "mode can be invoked by the -i/--interactive flag, which " + ++ "will try to guess as much as possible and prompt you for " + ++ "the rest. You can change init to always be interactive by " + ++ "setting the interactive flag in your configuration file. " + ++ "Command-line arguments are provided for scripting purposes.\n", commandNotes = Nothing, commandUsage = \pname -> "Usage: " ++ pname ++ " init [FLAGS]\n", diff --git a/cabal-install/changelog b/cabal-install/changelog index bb8d64e2dc..56e12d36e9 100644 --- a/cabal-install/changelog +++ b/cabal-install/changelog @@ -36,6 +36,7 @@ that make it possible to copy the executable instead of symlinking it * --symlink-bindir no longer controls the symlinking directory of v2-install (installdir controls both symlinking and copying now) + * Default to non-interactive init. * Add --test-wrapper that allows a prebuild script to set the test environment. * Add filterTestFlags: filter test-wrapper for Cabal < 3.0.0. * Cabal now only builds the minimum of a package for `v2-install` (#5754, #6091) -- GitLab