Skip to content

Commit

Permalink
graphex graph all fails when no modules match the query
Browse files Browse the repository at this point in the history
  • Loading branch information
ramirez7 committed Feb 29, 2024
1 parent 7e7c480 commit 93174c1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/Main.hs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
{-# LANGUAGE ApplicativeDo #-}
module Main where

import Control.Monad (when)
import Data.Aeson (encode)
import Data.Bool (bool)
import qualified Data.ByteString.Lazy as BL
import qualified Data.Csv as CSV
import Data.Foldable
import Data.List.NonEmpty (NonEmpty (..))
import qualified Data.List.NonEmpty as NE
import qualified Data.Map as Map
import Data.Maybe (fromMaybe)
import Data.Text (Text)
import qualified Data.Text as T
Expand Down Expand Up @@ -137,7 +139,8 @@ main = customExecParser (prefs showHelpOnError) opts >>= \case
AllDepsOn{..} -> do
let ms =
if | useRegex -> filter (\m -> any (m =~) patterns) (graphNodes graph)
| otherwise -> NE.toList patterns
| otherwise -> filter (flip Map.member (unGraph graph)) $ NE.toList patterns
when (null ms) $ error $ unwords ["No nodes in the graph match:", show patterns]
printStrs $ foldMap (allDepsOn graph) ms
Rankings -> printStrs $ fmap (\(n,m) -> m <> " - " <> (T.pack . show) n) $ rankings graph
FindLongest -> printStrs $ longest graph
Expand Down

0 comments on commit 93174c1

Please sign in to comment.