move the hledger application modules to Hledger and Hledger.Cli

This commit is contained in:
Simon Michael 2010-05-19 23:06:46 +00:00
parent 8b2600984c
commit 090c8b4dd6
20 changed files with 222 additions and 150 deletions

View File

@ -1,67 +0,0 @@
{-# LANGUAGE CPP #-}
{-|
The Commands package defines all the commands offered by the hledger
application, like \"register\" and \"balance\". This module exports all
the commands; you can also import individual modules if you prefer.
-}
module Commands.All (
module Commands.Add,
module Commands.Balance,
module Commands.Convert,
module Commands.Histogram,
module Commands.Print,
module Commands.Register,
module Commands.Stats,
#ifdef VTY
module Commands.UI,
#endif
#if defined(WEB) || defined(WEBHAPPSTACK)
module Commands.Web,
#endif
#ifdef CHART
module Commands.Chart,
#endif
tests_Commands
)
where
import Commands.Add
import Commands.Balance
import Commands.Convert
import Commands.Histogram
import Commands.Print
import Commands.Register
import Commands.Stats
#ifdef VTY
import Commands.UI
#endif
#if defined(WEB) || defined(WEBHAPPSTACK)
import Commands.Web
#endif
#ifdef CHART
import Commands.Chart
#endif
import Test.HUnit (Test(TestList))
tests_Commands = TestList
[
-- Commands.Add.tests_Add
-- ,Commands.Balance.tests_Balance
Commands.Convert.tests_Convert
-- ,Commands.Histogram.tests_Histogram
-- ,Commands.Print.tests_Print
,Commands.Register.tests_Register
-- ,Commands.Stats.tests_Stats
]
-- #ifdef VTY
-- ,Commands.UI.tests_UI
-- #endif
-- #if defined(WEB) || defined(WEBHAPPSTACK)
-- ,Commands.Web.tests_Web
-- #endif
-- #ifdef CHART
-- ,Commands.Chart.tests_Chart
-- #endif

View File

@ -5,11 +5,11 @@ A history-aware add command to help with data entry.
-}
module Commands.Add
module Hledger.Cli.Commands.Add
where
import Ledger
import Options
import Commands.Register (showRegisterReport)
import Hledger.Cli.Options
import Hledger.Cli.Commands.Register (showRegisterReport)
#if __GLASGOW_HASKELL__ <= 610
import Prelude hiding (putStr, putStrLn, getLine, appendFile)
import System.IO.UTF8
@ -19,7 +19,7 @@ import System.IO ( stderr, hFlush, hPutStrLn, hPutStr )
#endif
import System.IO.Error
import Text.ParserCombinators.Parsec
import Utils (ledgerFromStringWithOpts)
import Hledger.Utils (ledgerFromStringWithOpts)
import qualified Data.Foldable as Foldable (find)
-- | Read ledger transactions from the terminal, prompting for each field,

View File

@ -0,0 +1,67 @@
{-# LANGUAGE CPP #-}
{-|
The Commands package defines all the commands offered by the hledger
application, like \"register\" and \"balance\". This module exports all
the commands; you can also import individual modules if you prefer.
-}
module Hledger.Cli.Commands.All (
module Hledger.Cli.Commands.Add,
module Hledger.Cli.Commands.Balance,
module Hledger.Cli.Commands.Convert,
module Hledger.Cli.Commands.Histogram,
module Hledger.Cli.Commands.Print,
module Hledger.Cli.Commands.Register,
module Hledger.Cli.Commands.Stats,
#ifdef VTY
module Hledger.Cli.Commands.UI,
#endif
#if defined(WEB) || defined(WEBHAPPSTACK)
module Hledger.Cli.Commands.Web,
#endif
#ifdef CHART
module Hledger.Cli.Commands.Chart,
#endif
tests_Commands
)
where
import Hledger.Cli.Commands.Add
import Hledger.Cli.Commands.Balance
import Hledger.Cli.Commands.Convert
import Hledger.Cli.Commands.Histogram
import Hledger.Cli.Commands.Print
import Hledger.Cli.Commands.Register
import Hledger.Cli.Commands.Stats
#ifdef VTY
import Hledger.Cli.Commands.UI
#endif
#if defined(WEB) || defined(WEBHAPPSTACK)
import Hledger.Cli.Commands.Web
#endif
#ifdef CHART
import Hledger.Cli.Commands.Chart
#endif
import Test.HUnit (Test(TestList))
tests_Commands = TestList
[
-- Hledger.Cli.Commands.Add.tests_Add
-- ,Hledger.Cli.Commands.Balance.tests_Balance
Hledger.Cli.Commands.Convert.tests_Convert
-- ,Hledger.Cli.Commands.Histogram.tests_Histogram
-- ,Hledger.Cli.Commands.Print.tests_Print
,Hledger.Cli.Commands.Register.tests_Register
-- ,Hledger.Cli.Commands.Stats.tests_Stats
]
-- #ifdef VTY
-- ,Hledger.Cli.Commands.UI.tests_UI
-- #endif
-- #if defined(WEB) || defined(WEBHAPPSTACK)
-- ,Hledger.Cli.Commands.Web.tests_Web
-- #endif
-- #ifdef CHART
-- ,Hledger.Cli.Commands.Chart.tests_Chart
-- #endif

View File

@ -95,7 +95,7 @@ balance report:
-}
module Commands.Balance
module Hledger.Cli.Commands.Balance
where
import Ledger.Utils
import Ledger.Types
@ -103,7 +103,7 @@ import Ledger.Amount
import Ledger.AccountName
import Ledger.Posting
import Ledger.Ledger
import Options
import Hledger.Cli.Options
#if __GLASGOW_HASKELL__ <= 610
import Prelude hiding ( putStr )
import System.IO.UTF8

View File

@ -4,14 +4,14 @@ Generate balances pie chart
-}
module Commands.Chart
module Hledger.Cli.Commands.Chart
where
import Ledger.Utils
import Ledger.Types
import Ledger.Amount
import Ledger.Ledger
import Ledger.Commodity
import Options
import Hledger.Cli.Options
import Control.Monad (liftM3)
import Graphics.Rendering.Chart

View File

@ -3,9 +3,9 @@ Convert account data in CSV format (eg downloaded from a bank) to ledger
format, and print it on stdout. See the manual for more details.
-}
module Commands.Convert where
import Options (Opt(Debug))
import Version (versionstr)
module Hledger.Cli.Commands.Convert where
import Hledger.Cli.Options (Opt(Debug))
import Hledger.Version (versionstr)
import Ledger.Types (Ledger,AccountName,Transaction(..),Posting(..),PostingType(..))
import Ledger.Utils (strip, spacenonewline, restofline, parseWithCtx, assertParse, assertParseEqual)
import Ledger.Parse (someamount, emptyCtx, ledgeraccountname)

View File

@ -5,10 +5,10 @@ Print a histogram report.
-}
module Commands.Histogram
module Hledger.Cli.Commands.Histogram
where
import Ledger
import Options
import Hledger.Cli.Options
#if __GLASGOW_HASKELL__ <= 610
import Prelude hiding ( putStr )
import System.IO.UTF8

View File

@ -5,10 +5,10 @@ A ledger-compatible @print@ command.
-}
module Commands.Print
module Hledger.Cli.Commands.Print
where
import Ledger
import Options
import Hledger.Cli.Options
#if __GLASGOW_HASKELL__ <= 610
import Prelude hiding ( putStr )
import System.IO.UTF8

View File

@ -5,7 +5,7 @@ A ledger-compatible @register@ command.
-}
module Commands.Register (
module Hledger.Cli.Commands.Register (
register
,showRegisterReport
,showPostingWithBalance
@ -14,7 +14,7 @@ module Commands.Register (
import Safe (headMay, lastMay)
import Ledger
import Options
import Hledger.Cli.Options
#if __GLASGOW_HASKELL__ <= 610
import Prelude hiding ( putStr )
import System.IO.UTF8

View File

@ -5,10 +5,10 @@ Print some statistics for the ledger.
-}
module Commands.Stats
module Hledger.Cli.Commands.Stats
where
import Ledger
import Options
import Hledger.Cli.Options
#if __GLASGOW_HASKELL__ <= 610
import Prelude hiding ( putStr )
import System.IO.UTF8

View File

@ -4,15 +4,15 @@ A simple text UI for hledger, based on the vty library.
-}
module Commands.UI
module Hledger.Cli.Commands.UI
where
import Safe (headDef)
import Graphics.Vty
import Ledger
import Options
import Commands.Balance
import Commands.Register
import Commands.Print
import Hledger.Cli.Options
import Hledger.Cli.Commands.Balance
import Hledger.Cli.Commands.Register
import Hledger.Cli.Commands.Print
helpmsg = "(b)alance, (r)egister, (p)rint, (right) to drill down, (left) to back up, (q)uit"

View File

@ -4,7 +4,7 @@
A web-based UI.
-}
module Commands.Web
module Hledger.Cli.Commands.Web
where
#if __GLASGOW_HASKELL__ <= 610
import Codec.Binary.UTF8.String (decodeString)
@ -39,19 +39,19 @@ import HSP hiding (Request,catch)
import qualified HSP (Request(..))
import HSP.HTML (renderAsHTML)
import Commands.Add (ledgerAddTransaction)
import Commands.Balance
import Commands.Histogram
import Commands.Print
import Commands.Register
import Hledger.Cli.Commands.Add (ledgerAddTransaction)
import Hledger.Cli.Commands.Balance
import Hledger.Cli.Commands.Histogram
import Hledger.Cli.Commands.Print
import Hledger.Cli.Commands.Register
import Ledger
import Options hiding (value)
import Hledger.Cli.Options hiding (value)
#ifdef MAKE
import Paths_hledger_make (getDataFileName)
#else
import Paths_hledger (getDataFileName)
#endif
import Utils (openBrowserOn)
import Hledger.Utils (openBrowserOn)
-- import Debug.Trace
-- strace :: Show a => a -> a

View File

@ -5,18 +5,18 @@ benchmark scripts. As a side benefit, this avoids a weakness of sp, which
doesn't allow both #! and \{\-\# lines.
-}
module HledgerMain where
module Hledger.Cli.Main where
#if __GLASGOW_HASKELL__ <= 610
import Prelude hiding (putStr, putStrLn)
import System.IO.UTF8
#endif
import Commands.All
import Hledger.Cli.Commands.All
import Ledger
import Options
import Tests
import Utils (withLedgerDo)
import Version (versionmsg, binaryfilename)
import Hledger.Cli.Options
import Hledger.Tests
import Hledger.Utils (withLedgerDo)
import Hledger.Version (versionmsg, binaryfilename)
main :: IO ()
main = do

View File

@ -3,11 +3,11 @@
Command-line options for the application.
-}
module Options
module Hledger.Cli.Options
where
import System.Console.GetOpt
import System.Environment
import Version (timeprogname)
import Hledger.Version (timeprogname)
import Ledger.IO (myLedgerPath,myTimelogPath)
import Ledger.Utils
import Ledger.Types

View File

@ -26,7 +26,7 @@ $ hledger -f sample.ledger balance o
-}
module Tests
module Hledger.Tests
where
import qualified Data.Map as Map
import Data.Time.Format
@ -35,10 +35,10 @@ import Test.HUnit.Tools (runVerboseTests)
import System.Exit (exitFailure, exitWith, ExitCode(ExitSuccess)) -- base 3 compatible
import System.Time (ClockTime(TOD))
import Commands.All
import Hledger.Cli.Commands.All
import Ledger -- including testing utils in Ledger.Utils
import Options
import Utils
import Hledger.Cli.Options
import Hledger.Utils
-- | Run unit tests.

View File

@ -6,11 +6,11 @@ Utilities for top-level modules and ghci. See also "Ledger.IO" and
-}
module Utils
module Hledger.Utils
where
import Control.Monad.Error
import Ledger
import Options (Opt(..),ledgerFilePathFromOpts) -- ,optsToFilterSpec)
import Hledger.Cli.Options (Opt(..),ledgerFilePathFromOpts) -- ,optsToFilterSpec)
import System.Directory (doesFileExist)
import System.IO (stderr)
#if __GLASGOW_HASKELL__ <= 610

View File

@ -4,7 +4,7 @@ Version-related utilities. See the Makefile for details of our version
numbering policy.
-}
module Version
module Hledger.Version
where
import System.Info (os, arch)
import Ledger.Utils

View File

@ -31,8 +31,11 @@ MAIN=hledger.hs
SOURCEFILES:= \
$(MAIN) \
[A-Z]*hs \
Commands/[A-Z]*hs \
hledger-lib/Ledger/[A-Z]*hs
Hledger/*hs \
Hledger/Cli/*hs \
Hledger/Cli/Commands/*hs \
hledger-lib/*hs \
hledger-lib/Ledger/*hs
DOCFILES:=README README2 MANUAL NEWS CONTRIBUTORS SCREENSHOTS
BINARYFILENAME=`runhaskell ./hledger.hs --binary-filename`
PATCHLEVEL:=$(shell expr `darcs changes --count --from-tag=\\\\\.` - 1)
@ -457,8 +460,8 @@ VERSION3:=$(VERSION)
endif
# files which should be updated when the version changes
VERSIONSENSITIVEFILES=\
Version.hs \
hledger.cabal \
Hledger/Version.hs \
hledger-lib/hledger-lib.cabal \
Version.hs: $(VERSIONFILE)

View File

@ -51,38 +51,23 @@ flag chart
description: enable the pie chart generation
default: False
-- minimal library so cabal list and ghc-pkg list will show this package
library
exposed-modules:
Version
-- Build-Depends:
-- base >= 3 && < 5
-- ,containers
-- ,directory
-- ,filepath
-- ,old-time
-- ,parsec
-- ,time
-- ,utf8-string >= 0.3
-- ,HUnit
executable hledger
main-is: hledger.hs
other-modules:
HledgerMain
Options
Paths_hledger
Tests
Utils
Version
Commands.Add
Commands.All
Commands.Balance
Commands.Convert
Commands.Histogram
Commands.Print
Commands.Register
Commands.Stats
Hledger.Tests
Hledger.Utils
Hledger.Version
Hledger.Cli.Main
Hledger.Cli.Options
Hledger.Cli.Commands.Add
Hledger.Cli.Commands.All
Hledger.Cli.Commands.Balance
Hledger.Cli.Commands.Convert
Hledger.Cli.Commands.Histogram
Hledger.Cli.Commands.Print
Hledger.Cli.Commands.Register
Hledger.Cli.Commands.Stats
build-depends:
hledger-lib == 0.9
,HUnit
@ -107,13 +92,13 @@ executable hledger
if flag(vty)
cpp-options: -DVTY
other-modules:Commands.UI
other-modules:Hledger.Cli.Commands.UI
build-depends:
vty >= 4.0.0.1
if flag(web)
cpp-options: -DWEB
other-modules:Commands.Web
other-modules:Hledger.Cli.Commands.Web
build-depends:
hsp
,hsx
@ -128,7 +113,7 @@ executable hledger
if flag(webhappstack)
cpp-options: -DWEBHAPPSTACK
other-modules:Commands.Web
other-modules:Hledger.Cli.Commands.Web
build-depends:
hsp
,hsx
@ -147,7 +132,91 @@ executable hledger
if flag(chart)
cpp-options: -DCHART
other-modules:Commands.Chart
other-modules:Hledger.Cli.Commands.Chart
build-depends:
Chart >= 0.11
,colour
library
exposed-modules:
Hledger.Tests
Hledger.Utils
Hledger.Version
Hledger.Cli.Main
Hledger.Cli.Options
Hledger.Cli.Commands.Add
Hledger.Cli.Commands.All
Hledger.Cli.Commands.Balance
Hledger.Cli.Commands.Convert
Hledger.Cli.Commands.Histogram
Hledger.Cli.Commands.Print
Hledger.Cli.Commands.Register
Hledger.Cli.Commands.Stats
build-depends:
hledger-lib >= 0.10
,HUnit
,base >= 3 && < 5
,containers
,csv
,directory
,filepath
,mtl
,old-locale
,old-time
,parsec
,process
,regexpr >= 0.5.1
,safe >= 0.2
,testpack >= 1 && < 2
,time
,utf8-string >= 0.3
-- should set patchlevel here as in Makefile
cpp-options: -DPATCHLEVEL=0
if flag(vty)
cpp-options: -DVTY
exposed-modules:Hledger.Cli.Commands.UI
build-depends:
vty >= 4.0.0.1
if flag(web)
cpp-options: -DWEB
exposed-modules:Hledger.Cli.Commands.Web
build-depends:
hsp
,hsx
,xhtml >= 3000.2
,loli
,io-storage
,hack-contrib
,hack
,hack-handler-simpleserver
,HTTP >= 4000.0
,applicative-extras
if flag(webhappstack)
cpp-options: -DWEBHAPPSTACK
exposed-modules:Hledger.Cli.Commands.Web
build-depends:
hsp
,hsx
,xhtml >= 3000.2
,loli
,io-storage
,hack-contrib
,hack
,hack-handler-happstack
,happstack >= 0.3
,happstack-data >= 0.3
,happstack-server >= 0.3
,happstack-state >= 0.3
,HTTP >= 4000.0
,applicative-extras
if flag(chart)
cpp-options: -DCHART
exposed-modules:Hledger.Cli.Commands.Chart
build-depends:
Chart >= 0.11
,colour

View File

@ -36,4 +36,4 @@ See "Ledger.Ledger" for more examples.
-}
module Main where
import HledgerMain (main)
import Hledger.Cli.Main (main)