summaryrefslogtreecommitdiff
path: root/main/Bustle.hs
diff options
context:
space:
mode:
authorWill Thompson <will@willthompson.co.uk>2020-07-29 16:32:36 +0100
committerWill Thompson <will@willthompson.co.uk>2020-07-29 16:32:47 +0100
commitba56a44aac4585071e4ac09a66401939c3032424 (patch)
tree61d67762fdd38bda2ca70276db5f996304f24551 /main/Bustle.hs
parent1a4823c120bbe5f0119e9208d7b78d91a3decbd3 (diff)
Simplify Cabal file
At some point in the past 12 years, Cabal has gaine support for both internal libraries, and common stanzas. Using an internal library for everything except Bustle's entrypoint means tests don't need to list (and build!) all modules they use, and all the necessary dependencies and flags again.
Diffstat (limited to 'main/Bustle.hs')
-rw-r--r--main/Bustle.hs65
1 files changed, 65 insertions, 0 deletions
diff --git a/main/Bustle.hs b/main/Bustle.hs
new file mode 100644
index 0000000..0236569
--- /dev/null
+++ b/main/Bustle.hs
@@ -0,0 +1,65 @@
+{-
+Bustle: a tool to draw charts of D-Bus activity
+Copyright © 2008–2011 Collabora Ltd.
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+-}
+{-# LANGUAGE ScopedTypeVariables #-}
+module Main (main)
+where
+
+import System.IO (hPutStrLn, stderr)
+import System.Environment (getArgs)
+import System.Exit (exitFailure)
+import Control.Monad (when)
+import System.Glib.Utils (setApplicationName)
+import Bustle.Noninteractive
+import Bustle.Translation
+import Bustle.UI
+
+usage :: Bool
+ -> IO ()
+usage fatal = do
+ hPutStrLn stderr
+ "Usage:\n\
+ \ bustle [LOGFILE [...]]\n\
+ \ bustle --pair SESSION_LOGFILE SYSTEM_LOGFILE\n\
+ \\n\
+ \Or for batch-processing:\n\
+ \ bustle --count LOGFILE\n\
+ \ bustle --time LOGFILE\n\
+ \ bustle --dot LOGFILE"
+ when fatal exitFailure
+
+runOne :: (String -> IO ())
+ -> [String]
+ -> IO ()
+runOne f [filename] = f filename
+runOne _ _ = usage True
+
+main :: IO ()
+main = do
+ initTranslation
+ setApplicationName (__ "Bustle")
+ args <- getArgs
+
+ case args of
+ ["--help"] -> usage False
+ "--count":rest -> runOne runCount rest
+ "--time":rest -> runOne runTime rest
+ "--dot":rest -> runOne runDot rest
+ _ -> uiMain
+
+-- vim: sw=2 sts=2