Skip to content

Commit

Permalink
Fixup, dont show setup by default
Browse files Browse the repository at this point in the history
  • Loading branch information
fendor committed Jun 22, 2020
1 parent 055cb5a commit a7d45ea
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions src-exe/cabal-plan.hs
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,13 @@ parsePattern = either (Left . show) Right . P.runParser (patternP <* P.eof) () "
toCompType t = fail $ "Unknown component type: " ++ show t

prettyPattern :: Pattern -> T.Text
prettyPattern (Pattern pkg kind cname) =
maybe "" (<> ":") pkg
prettyPattern (Pattern pkg kind cname) =
maybe "" (<> ":") pkg
<> maybe "" ((<> ":") . prettyCompType) kind
<> fromMaybe "" cname
<> fromMaybe "" cname

prettyCompType :: CompType -> T.Text
prettyCompType compType = case compType of
prettyCompType compType = case compType of
CompTypeBench -> "bench"
CompTypeExe -> "exe"
CompTypeLib -> "lib"
Expand Down Expand Up @@ -331,18 +331,24 @@ main = do
depId <- findUniqueUnitOrExit plan depPat
doWhyDepends optsUseColors plan compId depId
where
findUniqueUnitOrExit :: PlanJson -> Pattern -> IO UnitId
findUniqueUnitOrExit p pat =
case findUnit p pat of
findUniqueUnitOrExit :: PlanJson -> Pattern -> IO UnitId
findUniqueUnitOrExit p pat =
case findUnit p pat of
[(_, uid, _)] -> pure uid
[] -> do
[] -> do
hPutStrLn stderr $ "Could not find any unit with pattern: " ++ T.unpack (prettyPattern pat)
exitFailure
xs -> do
xs
| [(_, uid, _)] <- filter nonSetupUnits xs -> pure uid
| otherwise -> do
hPutStrLn stderr $ "Ambiguous target \"" ++ T.unpack (prettyPattern pat) ++ "\". Found the following targets:"
for_ xs $ \(t, _, _) -> hPutStrLn stderr $ " " ++ T.unpack t
exitFailure

nonSetupUnits :: (Text, UnitId, CompName) -> Bool
nonSetupUnits (_, _, CompNameSetup) = False
nonSetupUnits _ = True

findPlan search = do
cwd <- getCurrentDirectory
(searchMethod, mProjRoot) <- case search of
Expand Down

0 comments on commit a7d45ea

Please sign in to comment.