handleArgs :: Flags -> [String] -> IO ()
handleArgs flags args
  | flagHelp    flags = printHelp
  | flagVersion flags = printVersion
  | otherwise         = do

    initialTrace <- case (args, flagTest flags) of
      ([filename], Nothing) -> return (Just (Left filename))
      ([], Just tracename)  -> return (Just (Right tracename))
      ([], Nothing)         -> return Nothing
      _                     -> printUsage >> exitFailure

    runGUI initialTrace

  where
    printVersion = putStrLn ("ThreadScope version " ++ showVersion version)
    printUsage   = putStrLn usageHeader
    usageHeader  = "Usage: threadscope [eventlog]\n" ++
                   "   or: threadscope [FLAGS]"
    helpHeader   = usageHeader ++ "\n\nFlags: "
    printHelp    = putStrLn (usageInfo helpHeader flagDescrs
                             ++ "\nFor more details see http://www.haskell.org/haskellwiki/ThreadScope_Tour\n")


-------------------------------------------------------------------------------
handleArgs :: Flags -> [String] -> IO ()
handleArgs flags args
  | flagHelp    flags = printHelp
  | flagVersion flags = printVersion
  | otherwise         = do

    initialTrace <- case (args, flagTest flags) of
      ([filename], Nothing) -> return (Just (Left filename))
      ([], Just tracename)  -> return (Just (Right tracename))
      ([], Nothing)         -> return Nothing
      _                     -> printUsage >> exitFailure

    runGUI initialTrace

  where
    printVersion = putStrLn ("ThreadScope version " ++ showVersion version)
    printUsage   = putStrLn usageHeader
    usageHeader  = "Usage: threadscope [eventlog]\n" ++
                   "   or: threadscope [FLAGS]"
    helpHeader   = usageHeader ++ "\n\nFlags: "
    printHelp    = putStrLn (usageInfo helpHeader flagDescrs
                             ++ "\nFor more details see http://www.haskell.org/haskellwiki/ThreadScope_Tour\n")


-------------------------------------------------------------------------------
handleArgs flags args
  | flagHelp    flags = printHelp
  | flagVersion flags = printVersion
  | otherwise         = do

    initialTrace <- case (args, flagTest flags) of
      ([filename], Nothing) -> return (Just (Left filename))
      ([], Just tracename)  -> return (Just (Right tracename))
      ([], Nothing)         -> return Nothing
      _                     -> printUsage >> exitFailure

    runGUI initialTrace

  where
    printVersion = putStrLn ("ThreadScope version " ++ showVersion version)
    printUsage   = putStrLn usageHeader
    usageHeader  = "Usage: threadscope [eventlog]\n" ++
                   "   or: threadscope [FLAGS]"
    helpHeader   = usageHeader ++ "\n\nFlags: "
    printHelp    = putStrLn (usageInfo helpHeader flagDescrs
                             ++ "\nFor more details see http://www.haskell.org/haskellwiki/ThreadScope_Tour\n")


-------------------------------------------------------------------------------