Skip to content

Commit

Permalink
stack ghci: Make shown options easily copy-pastable.
Browse files Browse the repository at this point in the history
Turns

		1. Package `p' component exe:myexe with main-is file ...

into

		1. Package `p' component p:exe:myexe with main-is file ...

so that you can easily copy-paste it into

    stack ghci p:exe:myexe
  • Loading branch information
nh2 committed Feb 22, 2019
1 parent ac71e9b commit 5b82545
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ Other enhancements:
* Stack parses and respects the `preferred-versions` information from
Hackage for choosing latest version of a package in some cases,
e.g. `stack unpack packagename`.
* The components output in the `The main module to load is ambiguous` message
now include package names so they can be more easily copy-pasted.
* Git repos are shared across multiple projects. See
[#3551](https://github.com/commercialhaskell/stack/issues/3551)
* Use en_US.UTF-8 locale by default in pure Nix mode so programs won't
Expand Down
7 changes: 5 additions & 2 deletions src/Stack/Ghci.hs
Original file line number Diff line number Diff line change
Expand Up @@ -561,10 +561,13 @@ figureOutMainFile bopts mainIsTargets targets0 packages = do
wantedPackageComponents bopts target (ghciPkgPackage pkg)
renderCandidate c@(pkgName,namedComponent,mainIs) =
let candidateIndex = T.pack . show . (+1) . fromMaybe 0 . elemIndex c
pkgNameText = T.pack (packageNameString pkgName)
in candidateIndex candidates <> ". Package `" <>
T.pack (packageNameString pkgName) <>
pkgNameText <>
"' component " <>
renderComp namedComponent <>
-- This is the format that can be directly copy-pasted as
-- an argument to `stack ghci`.
pkgNameText <> ":" renderComp namedComponent <>
" with main-is file: " <>
T.pack (toFilePath mainIs)
candidateIndices = take (length candidates) [1 :: Int ..]
Expand Down

0 comments on commit 5b82545

Please sign in to comment.