From 5b82545db334a38506bdb5a43537f6b270a9c2af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20Hamb=C3=BCchen?= Date: Fri, 22 Feb 2019 14:07:15 +0100 Subject: [PATCH] stack ghci: Make shown options easily copy-pastable. 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 --- ChangeLog.md | 2 ++ src/Stack/Ghci.hs | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 0e7caaaf4e..3d2a543d8f 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -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 diff --git a/src/Stack/Ghci.hs b/src/Stack/Ghci.hs index 4d9e606664..bdb8ba8ad8 100644 --- a/src/Stack/Ghci.hs +++ b/src/Stack/Ghci.hs @@ -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 ..]