From 2924632be38f65540f9af2ead567e1df37f24d88 Mon Sep 17 00:00:00 2001 From: Michael Sloan Date: Sun, 11 Feb 2018 12:07:05 -0800 Subject: [PATCH] Improve message when ghci is loaded without any packages #3651 --- src/Stack/Ghci.hs | 14 ++++++++------ src/Stack/PrettyPrint.hs | 20 +++++++++++++------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/Stack/Ghci.hs b/src/Stack/Ghci.hs index 1c414d8c0e..071bb9b4a6 100644 --- a/src/Stack/Ghci.hs +++ b/src/Stack/Ghci.hs @@ -747,17 +747,19 @@ targetWarnings stackYaml localTargets nonLocalTargets mfileTargets = do , flow "It can still be useful to specify these, as they will be passed to ghci via -package flags." ] when (null localTargets && isNothing mfileTargets) $ - prettyWarn $ vsep - [ flow "No local targets specified, so ghci will not use any options from your package.yaml / *.cabal files." + prettyNote $ vsep + [ flow "No local targets specified, so a plain ghci will be started with no package hiding or package options." + , "" + , flow "If you want to use package hiding and options, then you can try one of the following:" , "" - , flow "Potential ways to resolve this:" , bulletedList [ fillSep - [ flow "If you want to use the package.yaml / *.cabal package in the current directory, use" + [ flow "If you want to start a different project configuration than" <+> display stackYaml <> ", then you can use" , styleShell "stack init" - , flow "to create a new stack.yaml." + , flow "to create a new stack.yaml for the packages in the current directory." + , line ] - , flow "Add to the 'packages' field of" <+> display stackYaml + , flow "If you want to use the project configuration at" <+> display stackYaml <> ", then you can add to its 'packages' field." ] , "" ] diff --git a/src/Stack/PrettyPrint.hs b/src/Stack/PrettyPrint.hs index 38b09b221e..993a39cfb6 100644 --- a/src/Stack/PrettyPrint.hs +++ b/src/Stack/PrettyPrint.hs @@ -9,9 +9,9 @@ module Stack.PrettyPrint -- * Pretty printing functions displayPlain, displayWithColor -- * Logging based on pretty-print typeclass - , prettyDebug, prettyInfo, prettyWarn, prettyError, prettyWarnNoIndent, prettyErrorNoIndent - , prettyDebugL, prettyInfoL, prettyWarnL, prettyErrorL, prettyWarnNoIndentL, prettyErrorNoIndentL - , prettyDebugS, prettyInfoS, prettyWarnS, prettyErrorS, prettyWarnNoIndentS, prettyErrorNoIndentS + , prettyDebug, prettyInfo, prettyNote, prettyWarn, prettyError, prettyWarnNoIndent, prettyErrorNoIndent + , prettyDebugL, prettyInfoL, prettyNoteL, prettyWarnL, prettyErrorL, prettyWarnNoIndentL, prettyErrorNoIndentL + , prettyDebugS, prettyInfoS, prettyNoteS, prettyWarnS, prettyErrorS, prettyWarnNoIndentS, prettyErrorNoIndentS -- * Semantic styling functions -- | These are preferred to styling or colors directly, so that we can -- encourage consistency. @@ -67,11 +67,14 @@ prettyWith level f = logGeneric "" level <=< displayWithColor . f -- Note: I think keeping this section aligned helps spot errors, might be -- worth keeping the alignment in place. -prettyDebugWith, prettyInfoWith, prettyWarnWith, prettyErrorWith, prettyWarnNoIndentWith, prettyErrorNoIndentWith +prettyDebugWith, prettyInfoWith, prettyNoteWith, prettyWarnWith, prettyErrorWith, prettyWarnNoIndentWith, prettyErrorNoIndentWith :: (HasCallStack, HasRunner env, MonadReader env m, MonadIO m) => (a -> Doc AnsiAnn) -> a -> m () prettyDebugWith = prettyWith LevelDebug prettyInfoWith = prettyWith LevelInfo +prettyNoteWith f = prettyWith LevelInfo + ((line <>) . (styleGood "Note:" <+>) . + indentAfterLabel . f) prettyWarnWith f = prettyWith LevelWarn ((line <>) . (styleWarning "Warning:" <+>) . indentAfterLabel . f) @@ -83,31 +86,34 @@ prettyWarnNoIndentWith f = prettyWith LevelWarn prettyErrorNoIndentWith f = prettyWith LevelWarn ((line <>) . (styleError "Error:" <+>) . f) -prettyDebug, prettyInfo, prettyWarn, prettyError, prettyWarnNoIndent, prettyErrorNoIndent +prettyDebug, prettyInfo, prettyNote, prettyWarn, prettyError, prettyWarnNoIndent, prettyErrorNoIndent :: (HasCallStack, HasRunner env, MonadReader env m, MonadIO m) => Doc AnsiAnn -> m () prettyDebug = prettyDebugWith id prettyInfo = prettyInfoWith id +prettyNote = prettyNoteWith id prettyWarn = prettyWarnWith id prettyError = prettyErrorWith id prettyWarnNoIndent = prettyWarnNoIndentWith id prettyErrorNoIndent = prettyErrorNoIndentWith id -prettyDebugL, prettyInfoL, prettyWarnL, prettyErrorL, prettyWarnNoIndentL, prettyErrorNoIndentL +prettyDebugL, prettyInfoL, prettyNoteL, prettyWarnL, prettyErrorL, prettyWarnNoIndentL, prettyErrorNoIndentL :: (HasCallStack, HasRunner env, MonadReader env m, MonadIO m) => [Doc AnsiAnn] -> m () prettyDebugL = prettyDebugWith fillSep prettyInfoL = prettyInfoWith fillSep +prettyNoteL = prettyNoteWith fillSep prettyWarnL = prettyWarnWith fillSep prettyErrorL = prettyErrorWith fillSep prettyWarnNoIndentL = prettyWarnNoIndentWith fillSep prettyErrorNoIndentL = prettyErrorNoIndentWith fillSep -prettyDebugS, prettyInfoS, prettyWarnS, prettyErrorS, prettyWarnNoIndentS, prettyErrorNoIndentS +prettyDebugS, prettyInfoS, prettyNoteS, prettyWarnS, prettyErrorS, prettyWarnNoIndentS, prettyErrorNoIndentS :: (HasCallStack, HasRunner env, MonadReader env m, MonadIO m) => String -> m () prettyDebugS = prettyDebugWith flow prettyInfoS = prettyInfoWith flow +prettyNoteS = prettyNoteWith flow prettyWarnS = prettyWarnWith flow prettyErrorS = prettyErrorWith flow prettyWarnNoIndentS = prettyWarnNoIndentWith flow