refactor: consistent main modules in add-ons
This commit is contained in:
parent
1127c3f52f
commit
fd10736373
@ -1,18 +1,12 @@
|
|||||||
|
{-# LANGUAGE CPP #-}
|
||||||
{-|
|
{-|
|
||||||
|
hledger-web - a hledger add-on providing rudimentary pie chart generation.
|
||||||
Generate balances pie chart
|
Copyright (c) 2007-2010 Simon Michael <simon@joyful.com>
|
||||||
|
Released under GPL version 3 or later.
|
||||||
-}
|
-}
|
||||||
|
|
||||||
module Hledger.Cli.Chart
|
module Hledger.Chart.Main
|
||||||
where
|
where
|
||||||
import Hledger.Data.Utils
|
|
||||||
import Hledger.Data.Types
|
|
||||||
import Hledger.Data.Amount
|
|
||||||
import Hledger.Data.Ledger
|
|
||||||
import Hledger.Data.Commodity
|
|
||||||
import Hledger.Cli.Options
|
|
||||||
|
|
||||||
import Control.Monad (liftM3)
|
import Control.Monad (liftM3)
|
||||||
import Graphics.Rendering.Chart
|
import Graphics.Rendering.Chart
|
||||||
import Data.Colour
|
import Data.Colour
|
||||||
@ -22,6 +16,36 @@ import Data.Colour.RGBSpace.HSL (hsl)
|
|||||||
import Data.Colour.SRGB.Linear (rgb)
|
import Data.Colour.SRGB.Linear (rgb)
|
||||||
import Data.List
|
import Data.List
|
||||||
import Safe (readDef)
|
import Safe (readDef)
|
||||||
|
#if __GLASGOW_HASKELL__ <= 610
|
||||||
|
import Prelude hiding (putStr, putStrLn)
|
||||||
|
import System.IO.UTF8 (putStr, putStrLn)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
import Hledger.Chart
|
||||||
|
import Hledger.Cli.Commands
|
||||||
|
import Hledger.Cli.Options
|
||||||
|
import Hledger.Cli.Tests
|
||||||
|
import Hledger.Cli.Utils (withJournalDo)
|
||||||
|
import Hledger.Cli.Version (versionmsg, binaryfilename)
|
||||||
|
import Hledger.Data
|
||||||
|
|
||||||
|
|
||||||
|
main :: IO ()
|
||||||
|
main = do
|
||||||
|
(opts, cmd, args) <- parseArguments
|
||||||
|
run cmd opts args
|
||||||
|
where
|
||||||
|
run cmd opts args
|
||||||
|
| Help `elem` opts = putStr help1
|
||||||
|
| HelpOptions `elem` opts = putStr help2
|
||||||
|
| HelpAll `elem` opts = putStr $ help1 ++ "\n" ++ help2
|
||||||
|
| Version `elem` opts = putStrLn versionmsg
|
||||||
|
| BinaryFilename `elem` opts = putStrLn binaryfilename
|
||||||
|
| null cmd = maybe (putStr help1) (withJournalDo opts args cmd) defaultcmd
|
||||||
|
| cmd `isPrefixOf` "chart" = withJournalDo opts args cmd chart
|
||||||
|
| otherwise = putStr help1
|
||||||
|
|
||||||
|
defaultcmd = Just chart
|
||||||
|
|
||||||
-- | Generate an image with the pie chart and write it to a file
|
-- | Generate an image with the pie chart and write it to a file
|
||||||
chart :: [Opt] -> [String] -> Journal -> IO ()
|
chart :: [Opt] -> [String] -> Journal -> IO ()
|
||||||
@ -1,38 +0,0 @@
|
|||||||
{-# LANGUAGE CPP #-}
|
|
||||||
{-|
|
|
||||||
hledger-web - a hledger add-on providing rudimentary pie chart generation.
|
|
||||||
Copyright (c) 2007-2010 Simon Michael <simon@joyful.com>
|
|
||||||
Released under GPL version 3 or later.
|
|
||||||
-}
|
|
||||||
|
|
||||||
module Main where
|
|
||||||
|
|
||||||
#if __GLASGOW_HASKELL__ <= 610
|
|
||||||
import Prelude hiding (putStr, putStrLn)
|
|
||||||
import System.IO.UTF8 (putStr, putStrLn)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
import Hledger.Chart
|
|
||||||
import Hledger.Cli.Commands
|
|
||||||
import Hledger.Cli.Options
|
|
||||||
import Hledger.Cli.Tests
|
|
||||||
import Hledger.Cli.Utils (withJournalDo)
|
|
||||||
import Hledger.Cli.Version (versionmsg, binaryfilename)
|
|
||||||
import Hledger.Data
|
|
||||||
|
|
||||||
main :: IO ()
|
|
||||||
main = do
|
|
||||||
(opts, cmd, args) <- parseArguments
|
|
||||||
run cmd opts args
|
|
||||||
where
|
|
||||||
run cmd opts args
|
|
||||||
| Help `elem` opts = putStr help1
|
|
||||||
| HelpOptions `elem` opts = putStr help2
|
|
||||||
| HelpAll `elem` opts = putStr $ help1 ++ "\n" ++ help2
|
|
||||||
| Version `elem` opts = putStrLn versionmsg
|
|
||||||
| BinaryFilename `elem` opts = putStrLn binaryfilename
|
|
||||||
| null cmd = maybe (putStr help1) (withJournalDo opts args cmd) defaultcmd
|
|
||||||
| cmd `isPrefixOf` "chart" = withJournalDo opts args cmd chart
|
|
||||||
| otherwise = putStr help1
|
|
||||||
|
|
||||||
defaultcmd = Just chart
|
|
||||||
@ -23,10 +23,10 @@ source-repository head
|
|||||||
location: http://joyful.com/repos/hledger
|
location: http://joyful.com/repos/hledger
|
||||||
|
|
||||||
executable hledger-chart
|
executable hledger-chart
|
||||||
main-is: Main.hs
|
main-is: hledger-chart.hs
|
||||||
ghc-options: -threaded -W
|
ghc-options: -threaded -W
|
||||||
other-modules:
|
other-modules:
|
||||||
Hledger.Chart
|
Hledger.Chart.Main
|
||||||
build-depends:
|
build-depends:
|
||||||
hledger == 0.13
|
hledger == 0.13
|
||||||
,hledger-lib == 0.13
|
,hledger-lib == 0.13
|
||||||
|
|||||||
@ -1,19 +1,44 @@
|
|||||||
{-|
|
{-# LANGUAGE CPP #-}
|
||||||
|
{-|
|
||||||
A simple text UI for hledger, based on the vty library.
|
hledger-vty - a hledger add-on providing a curses-style interface.
|
||||||
|
Copyright (c) 2007-2010 Simon Michael <simon@joyful.com>
|
||||||
|
Released under GPL version 3 or later.
|
||||||
-}
|
-}
|
||||||
|
|
||||||
module Hledger.Vty
|
module Hledger.Vty.Main where
|
||||||
where
|
|
||||||
|
#if __GLASGOW_HASKELL__ <= 610
|
||||||
|
import Prelude hiding (putStr, putStrLn)
|
||||||
|
import System.IO.UTF8 (putStr, putStrLn)
|
||||||
|
#endif
|
||||||
import Safe (headDef)
|
import Safe (headDef)
|
||||||
import Graphics.Vty
|
import Graphics.Vty
|
||||||
import Hledger.Data
|
|
||||||
import Hledger.Cli.Options
|
|
||||||
import Hledger.Cli.Balance
|
|
||||||
import Hledger.Cli.Register
|
|
||||||
import Hledger.Cli.Print
|
|
||||||
|
|
||||||
|
import Hledger.Cli.Balance
|
||||||
|
import Hledger.Cli.Options
|
||||||
|
import Hledger.Cli.Print
|
||||||
|
import Hledger.Cli.Register
|
||||||
|
import Hledger.Cli.Utils (withJournalDo)
|
||||||
|
import Hledger.Cli.Version (versionmsg, binaryfilename)
|
||||||
|
import Hledger.Data
|
||||||
|
|
||||||
|
|
||||||
|
main :: IO ()
|
||||||
|
main = do
|
||||||
|
(opts, cmd, args) <- parseArguments
|
||||||
|
run cmd opts args
|
||||||
|
where
|
||||||
|
run cmd opts args
|
||||||
|
| Help `elem` opts = putStr help1
|
||||||
|
| HelpOptions `elem` opts = putStr help2
|
||||||
|
| HelpAll `elem` opts = putStr $ help1 ++ "\n" ++ help2
|
||||||
|
| Version `elem` opts = putStrLn versionmsg
|
||||||
|
| BinaryFilename `elem` opts = putStrLn binaryfilename
|
||||||
|
| null cmd = maybe (putStr help1) (withJournalDo opts args cmd) defaultcmd
|
||||||
|
| cmd `isPrefixOf` "vty" = withJournalDo opts args cmd vty
|
||||||
|
| otherwise = putStr help1
|
||||||
|
|
||||||
|
defaultcmd = Just vty
|
||||||
|
|
||||||
helpmsg = "(b)alance, (r)egister, (p)rint, (right) to drill down, (left) to back up, (q)uit"
|
helpmsg = "(b)alance, (r)egister, (p)rint, (right) to drill down, (left) to back up, (q)uit"
|
||||||
|
|
||||||
@ -1,36 +0,0 @@
|
|||||||
{-# LANGUAGE CPP #-}
|
|
||||||
{-|
|
|
||||||
hledger-vty - a hledger add-on providing a curses-style interface.
|
|
||||||
Copyright (c) 2007-2010 Simon Michael <simon@joyful.com>
|
|
||||||
Released under GPL version 3 or later.
|
|
||||||
-}
|
|
||||||
|
|
||||||
module Main where
|
|
||||||
|
|
||||||
#if __GLASGOW_HASKELL__ <= 610
|
|
||||||
import Prelude hiding (putStr, putStrLn)
|
|
||||||
import System.IO.UTF8 (putStr, putStrLn)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
import Hledger.Cli.Options
|
|
||||||
import Hledger.Cli.Utils (withJournalDo)
|
|
||||||
import Hledger.Cli.Version (versionmsg, binaryfilename)
|
|
||||||
import Hledger.Data
|
|
||||||
import Hledger.Vty
|
|
||||||
|
|
||||||
main :: IO ()
|
|
||||||
main = do
|
|
||||||
(opts, cmd, args) <- parseArguments
|
|
||||||
run cmd opts args
|
|
||||||
where
|
|
||||||
run cmd opts args
|
|
||||||
| Help `elem` opts = putStr help1
|
|
||||||
| HelpOptions `elem` opts = putStr help2
|
|
||||||
| HelpAll `elem` opts = putStr $ help1 ++ "\n" ++ help2
|
|
||||||
| Version `elem` opts = putStrLn versionmsg
|
|
||||||
| BinaryFilename `elem` opts = putStrLn binaryfilename
|
|
||||||
| null cmd = maybe (putStr help1) (withJournalDo opts args cmd) defaultcmd
|
|
||||||
| cmd `isPrefixOf` "vty" = withJournalDo opts args cmd vty
|
|
||||||
| otherwise = putStr help1
|
|
||||||
|
|
||||||
defaultcmd = Just vty
|
|
||||||
@ -24,10 +24,10 @@ source-repository head
|
|||||||
location: http://joyful.com/repos/hledger
|
location: http://joyful.com/repos/hledger
|
||||||
|
|
||||||
executable hledger-vty
|
executable hledger-vty
|
||||||
main-is: Main.hs
|
main-is: hledger-vty.hs
|
||||||
ghc-options: -threaded -W
|
ghc-options: -threaded -W
|
||||||
other-modules:
|
other-modules:
|
||||||
Hledger.Vty
|
Hledger.Vty.Main
|
||||||
build-depends:
|
build-depends:
|
||||||
hledger == 0.13
|
hledger == 0.13
|
||||||
,hledger-lib == 0.13
|
,hledger-lib == 0.13
|
||||||
|
|||||||
@ -5,7 +5,7 @@ Copyright (c) 2007-2010 Simon Michael <simon@joyful.com>
|
|||||||
Released under GPL version 3 or later.
|
Released under GPL version 3 or later.
|
||||||
-}
|
-}
|
||||||
|
|
||||||
module Main where
|
module Hledger.Web.Main where
|
||||||
|
|
||||||
#if __GLASGOW_HASKELL__ <= 610
|
#if __GLASGOW_HASKELL__ <= 610
|
||||||
import Prelude hiding (putStr, putStrLn)
|
import Prelude hiding (putStr, putStrLn)
|
||||||
@ -36,11 +36,12 @@ Flag production
|
|||||||
Default: False
|
Default: False
|
||||||
|
|
||||||
executable hledger-web
|
executable hledger-web
|
||||||
main-is: Main.hs
|
main-is: hledger-web.hs
|
||||||
ghc-options: -threaded -W
|
ghc-options: -threaded -W
|
||||||
if flag(production)
|
if flag(production)
|
||||||
cpp-options: -DPRODUCTION
|
cpp-options: -DPRODUCTION
|
||||||
other-modules:
|
other-modules:
|
||||||
|
Hledger.Web.Main
|
||||||
Hledger.Web.App
|
Hledger.Web.App
|
||||||
Hledger.Web.Files
|
Hledger.Web.Files
|
||||||
Hledger.Web.Settings
|
Hledger.Web.Settings
|
||||||
|
|||||||
2
hledger-web/hledger-web.hs
Normal file
2
hledger-web/hledger-web.hs
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
#!/usr/bin/env runhaskell
|
||||||
|
import Hledger.Web.Main (main)
|
||||||
Loading…
Reference in New Issue
Block a user