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,6 +72,9 @@ 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
|
||||||
|
if null $ jtxns j
|
||||||
|
then putStrLn "This journal has no transactions, can't make a chart." >> exitFailure
|
||||||
|
else do
|
||||||
let chart = genPie opts (optsToFilterSpec opts args t) j
|
let chart = genPie opts (optsToFilterSpec opts args t) j
|
||||||
renderableToPNGFile (toRenderable chart) w h filename
|
renderableToPNGFile (toRenderable chart) w h filename
|
||||||
return ()
|
return ()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user