chart: give a meaningful error message for empty journals
This commit is contained in:
parent
b8e3306819
commit
3979885037
@ -16,6 +16,7 @@ import Data.Colour.SRGB.Linear (rgb)
|
|||||||
import Data.List
|
import Data.List
|
||||||
import Safe (readDef)
|
import Safe (readDef)
|
||||||
import System.Console.GetOpt
|
import System.Console.GetOpt
|
||||||
|
import System.Exit (exitFailure)
|
||||||
#if __GLASGOW_HASKELL__ <= 610
|
#if __GLASGOW_HASKELL__ <= 610
|
||||||
import Prelude hiding (putStr, putStrLn)
|
import Prelude hiding (putStr, putStrLn)
|
||||||
import System.IO.UTF8 (putStr, putStrLn)
|
import System.IO.UTF8 (putStr, putStrLn)
|
||||||
@ -71,12 +72,15 @@ main = do
|
|||||||
chart :: [Opt] -> [String] -> Journal -> IO ()
|
chart :: [Opt] -> [String] -> Journal -> IO ()
|
||||||
chart opts args j = do
|
chart opts args j = do
|
||||||
t <- getCurrentLocalTime
|
t <- getCurrentLocalTime
|
||||||
let chart = genPie opts (optsToFilterSpec opts args t) j
|
if null $ jtxns j
|
||||||
renderableToPNGFile (toRenderable chart) w h filename
|
then putStrLn "This journal has no transactions, can't make a chart." >> exitFailure
|
||||||
return ()
|
else do
|
||||||
where
|
let chart = genPie opts (optsToFilterSpec opts args t) j
|
||||||
filename = getOption opts ChartOutput defchartoutput
|
renderableToPNGFile (toRenderable chart) w h filename
|
||||||
(w,h) = parseSize $ getOption opts ChartSize defchartsize
|
return ()
|
||||||
|
where
|
||||||
|
filename = getOption opts ChartOutput defchartoutput
|
||||||
|
(w,h) = parseSize $ getOption opts ChartSize defchartsize
|
||||||
|
|
||||||
-- | Extract string option value from a list of options or use the default
|
-- | Extract string option value from a list of options or use the default
|
||||||
getOption :: [Opt] -> (String->Opt) -> String -> String
|
getOption :: [Opt] -> (String->Opt) -> String -> String
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user