Skip to content

Commit

Permalink
Improve message when ghci is loaded without any packages #3651
Browse files Browse the repository at this point in the history
  • Loading branch information
mgsloan committed Feb 11, 2018
1 parent e08ccaf commit 2924632
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
14 changes: 8 additions & 6 deletions src/Stack/Ghci.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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."
]
, ""
]
Expand Down
20 changes: 13 additions & 7 deletions src/Stack/PrettyPrint.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit 2924632

Please sign in to comment.