From 29ac59757dfe6e08eb2b08ffdb81edb5959b241d Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Sat, 14 Mar 2009 20:25:41 +0100
Subject: [PATCH] Abstract the version format into a function

This patch moves the version string creation into a function in Utils
which shows some more information.
---
 src/Utils.hs | 16 ++++++++++++++--
 src/hbal.hs  |  2 +-
 src/hn1.hs   |  2 +-
 3 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/src/Utils.hs b/src/Utils.hs
index 5325d6e13..e092f7204 100644
--- a/src/Utils.hs
+++ b/src/Utils.hs
@@ -2,11 +2,15 @@
 
 module Utils where
 
-import Data.List
 import Data.Either
+import Data.List
+import qualified Data.Version
+import Monad
 import System
 import System.IO
-import Monad
+import System.Info
+import Text.Printf
+import qualified Version
 
 import Debug.Trace
 
@@ -78,3 +82,11 @@ readData fn host = do
          putStrLn $ fromLeft nd
          exitWith $ ExitFailure 1
   return $ fromRight nd
+
+showVersion :: String -- ^ The program name
+            -> String -- ^ The formatted version and other information data
+showVersion name =
+    printf "%s %s\ncompiled with %s %s\nrunning on %s %s\n"
+           name Version.version
+           compilerName (Data.Version.showVersion compilerVersion)
+           os arch
diff --git a/src/hbal.hs b/src/hbal.hs
index 9f7c1ddc2..fea3f9ff5 100644
--- a/src/hbal.hs
+++ b/src/hbal.hs
@@ -140,7 +140,7 @@ main = do
   (opts, _) <- parseOpts cmd_args
 
   when (optShowVer opts) $ do
-         printf "hbal %s\n" Version.version
+         putStr $ showVersion "hbal"
          exitWith ExitSuccess
 
   let oneline = optOneline opts
diff --git a/src/hn1.hs b/src/hn1.hs
index 9ab2d2bf7..2c8af7bba 100644
--- a/src/hn1.hs
+++ b/src/hn1.hs
@@ -132,7 +132,7 @@ main = do
   (opts, _) <- parseOpts cmd_args
 
   when (optShowVer opts) $ do
-         printf "hn1 %s\n" Version.version
+         printf $ showVersion "hn1"
          exitWith ExitSuccess
 
   let min_depth = optMinDepth opts
-- 
GitLab