From abb470aadbb268a834972b2cddb4a8f0b7bdb6ad Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Sat, 14 Apr 2012 20:35:51 +0000 Subject: [PATCH] use shakespeare-text to help lay out incomestatement's output --- hledger-lib/hledger-lib.cabal | 1 + hledger/Hledger/Cli/Incomestatement.hs | 16 ++++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/hledger-lib/hledger-lib.cabal b/hledger-lib/hledger-lib.cabal index f684f2b80..ac94aadc7 100644 --- a/hledger-lib/hledger-lib.cabal +++ b/hledger-lib/hledger-lib.cabal @@ -66,6 +66,7 @@ library ,parsec ,regexpr >= 0.5.1 ,safe >= 0.2 + ,shakespeare-text >= 1.0 && < 1.1 ,split == 0.1.* ,time ,utf8-string >= 0.3.5 && < 0.4 diff --git a/hledger/Hledger/Cli/Incomestatement.hs b/hledger/Hledger/Cli/Incomestatement.hs index bc44a5c7d..85d05fd43 100644 --- a/hledger/Hledger/Cli/Incomestatement.hs +++ b/hledger/Hledger/Cli/Incomestatement.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE QuasiQuotes, TemplateHaskell, OverloadedStrings #-} {-| The @incomestatement@ command prints a fairly standard income statement (profit & loss) report. @@ -9,24 +10,23 @@ module Hledger.Cli.Incomestatement ( ,tests_Hledger_Cli_Incomestatement ) where -import Data.List +import qualified Data.Text.Lazy.IO as LT import Test.HUnit +import Text.Shakespeare.Text import Hledger -import Prelude hiding (putStr) -import Hledger.Utils.UTF8IOCompat (putStr) import Hledger.Cli.Options import Hledger.Cli.Balance - -- | Print a standard income statement. incomestatement :: CliOpts -> Journal -> IO () incomestatement CliOpts{reportopts_=ropts} j = do - let lines = case formatFromOpts ropts of - Left err -> [err] - Right _ -> accountsReportAsText ropts $ accountsReport2 ropts (journalProfitAndLossAccountQuery j) j - putStr $ unlines lines + let report = accountsReport2 ropts (journalProfitAndLossAccountQuery j) j + LT.putStr $ [lt|Income Statement +#{unlines $ accountsReportAsText ropts report}|] + +tests_Hledger_Cli_Incomestatement :: Test tests_Hledger_Cli_Incomestatement = TestList [ ]