Skip to content

Commit 2924632

Browse files
committed
Improve message when ghci is loaded without any packages commercialhaskell#3651
1 parent e08ccaf commit 2924632

2 files changed

Lines changed: 21 additions & 13 deletions

File tree

src/Stack/Ghci.hs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -747,17 +747,19 @@ targetWarnings stackYaml localTargets nonLocalTargets mfileTargets = do
747747
, flow "It can still be useful to specify these, as they will be passed to ghci via -package flags."
748748
]
749749
when (null localTargets && isNothing mfileTargets) $
750-
prettyWarn $ vsep
751-
[ flow "No local targets specified, so ghci will not use any options from your package.yaml / *.cabal files."
750+
prettyNote $ vsep
751+
[ flow "No local targets specified, so a plain ghci will be started with no package hiding or package options."
752+
, ""
753+
, flow "If you want to use package hiding and options, then you can try one of the following:"
752754
, ""
753-
, flow "Potential ways to resolve this:"
754755
, bulletedList
755756
[ fillSep
756-
[ flow "If you want to use the package.yaml / *.cabal package in the current directory, use"
757+
[ flow "If you want to start a different project configuration than" <+> display stackYaml <> ", then you can use"
757758
, styleShell "stack init"
758-
, flow "to create a new stack.yaml."
759+
, flow "to create a new stack.yaml for the packages in the current directory."
760+
, line
759761
]
760-
, flow "Add to the 'packages' field of" <+> display stackYaml
762+
, flow "If you want to use the project configuration at" <+> display stackYaml <> ", then you can add to its 'packages' field."
761763
]
762764
, ""
763765
]

src/Stack/PrettyPrint.hs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ module Stack.PrettyPrint
99
-- * Pretty printing functions
1010
displayPlain, displayWithColor
1111
-- * Logging based on pretty-print typeclass
12-
, prettyDebug, prettyInfo, prettyWarn, prettyError, prettyWarnNoIndent, prettyErrorNoIndent
13-
, prettyDebugL, prettyInfoL, prettyWarnL, prettyErrorL, prettyWarnNoIndentL, prettyErrorNoIndentL
14-
, prettyDebugS, prettyInfoS, prettyWarnS, prettyErrorS, prettyWarnNoIndentS, prettyErrorNoIndentS
12+
, prettyDebug, prettyInfo, prettyNote, prettyWarn, prettyError, prettyWarnNoIndent, prettyErrorNoIndent
13+
, prettyDebugL, prettyInfoL, prettyNoteL, prettyWarnL, prettyErrorL, prettyWarnNoIndentL, prettyErrorNoIndentL
14+
, prettyDebugS, prettyInfoS, prettyNoteS, prettyWarnS, prettyErrorS, prettyWarnNoIndentS, prettyErrorNoIndentS
1515
-- * Semantic styling functions
1616
-- | These are preferred to styling or colors directly, so that we can
1717
-- encourage consistency.
@@ -67,11 +67,14 @@ prettyWith level f = logGeneric "" level <=< displayWithColor . f
6767
-- Note: I think keeping this section aligned helps spot errors, might be
6868
-- worth keeping the alignment in place.
6969

70-
prettyDebugWith, prettyInfoWith, prettyWarnWith, prettyErrorWith, prettyWarnNoIndentWith, prettyErrorNoIndentWith
70+
prettyDebugWith, prettyInfoWith, prettyNoteWith, prettyWarnWith, prettyErrorWith, prettyWarnNoIndentWith, prettyErrorNoIndentWith
7171
:: (HasCallStack, HasRunner env, MonadReader env m, MonadIO m)
7272
=> (a -> Doc AnsiAnn) -> a -> m ()
7373
prettyDebugWith = prettyWith LevelDebug
7474
prettyInfoWith = prettyWith LevelInfo
75+
prettyNoteWith f = prettyWith LevelInfo
76+
((line <>) . (styleGood "Note:" <+>) .
77+
indentAfterLabel . f)
7578
prettyWarnWith f = prettyWith LevelWarn
7679
((line <>) . (styleWarning "Warning:" <+>) .
7780
indentAfterLabel . f)
@@ -83,31 +86,34 @@ prettyWarnNoIndentWith f = prettyWith LevelWarn
8386
prettyErrorNoIndentWith f = prettyWith LevelWarn
8487
((line <>) . (styleError "Error:" <+>) . f)
8588

86-
prettyDebug, prettyInfo, prettyWarn, prettyError, prettyWarnNoIndent, prettyErrorNoIndent
89+
prettyDebug, prettyInfo, prettyNote, prettyWarn, prettyError, prettyWarnNoIndent, prettyErrorNoIndent
8790
:: (HasCallStack, HasRunner env, MonadReader env m, MonadIO m)
8891
=> Doc AnsiAnn -> m ()
8992
prettyDebug = prettyDebugWith id
9093
prettyInfo = prettyInfoWith id
94+
prettyNote = prettyNoteWith id
9195
prettyWarn = prettyWarnWith id
9296
prettyError = prettyErrorWith id
9397
prettyWarnNoIndent = prettyWarnNoIndentWith id
9498
prettyErrorNoIndent = prettyErrorNoIndentWith id
9599

96-
prettyDebugL, prettyInfoL, prettyWarnL, prettyErrorL, prettyWarnNoIndentL, prettyErrorNoIndentL
100+
prettyDebugL, prettyInfoL, prettyNoteL, prettyWarnL, prettyErrorL, prettyWarnNoIndentL, prettyErrorNoIndentL
97101
:: (HasCallStack, HasRunner env, MonadReader env m, MonadIO m)
98102
=> [Doc AnsiAnn] -> m ()
99103
prettyDebugL = prettyDebugWith fillSep
100104
prettyInfoL = prettyInfoWith fillSep
105+
prettyNoteL = prettyNoteWith fillSep
101106
prettyWarnL = prettyWarnWith fillSep
102107
prettyErrorL = prettyErrorWith fillSep
103108
prettyWarnNoIndentL = prettyWarnNoIndentWith fillSep
104109
prettyErrorNoIndentL = prettyErrorNoIndentWith fillSep
105110

106-
prettyDebugS, prettyInfoS, prettyWarnS, prettyErrorS, prettyWarnNoIndentS, prettyErrorNoIndentS
111+
prettyDebugS, prettyInfoS, prettyNoteS, prettyWarnS, prettyErrorS, prettyWarnNoIndentS, prettyErrorNoIndentS
107112
:: (HasCallStack, HasRunner env, MonadReader env m, MonadIO m)
108113
=> String -> m ()
109114
prettyDebugS = prettyDebugWith flow
110115
prettyInfoS = prettyInfoWith flow
116+
prettyNoteS = prettyNoteWith flow
111117
prettyWarnS = prettyWarnWith flow
112118
prettyErrorS = prettyErrorWith flow
113119
prettyWarnNoIndentS = prettyWarnNoIndentWith flow

0 commit comments

Comments
 (0)