close: fix ghci build / make build working-dir-independent again

This commit is contained in:
Simon Michael 2019-01-22 21:43:43 -08:00
parent 00253678a9
commit fcb33c4f0c
4 changed files with 24 additions and 8 deletions

View File

@ -1,5 +1,5 @@
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE TemplateHaskell #-}
module Hledger.Cli.Commands.Close ( module Hledger.Cli.Commands.Close (
closemode closemode
@ -9,16 +9,15 @@ where
import Control.Monad (when) import Control.Monad (when)
import Data.Maybe import Data.Maybe
import Data.String.Here
import Data.Time.Calendar import Data.Time.Calendar
import Hledger
import Hledger.Cli.CliOptions
import System.Console.CmdArgs.Explicit as C import System.Console.CmdArgs.Explicit as C
import Hledger
import Hledger.Cli.CliOptions
import Hledger.Cli.Utils (hereFileRelativeToPackage)
closemode = hledgerCommandMode closemode = hledgerCommandMode
[hereFile|Hledger/Cli/Commands/Close.md|] $(hereFileRelativeToPackage "Hledger/Cli/Commands/Close.md")
-- XXX need the hledger/ eg for ghci.. file-embed's makeRelativeToProject should help
-- ($(makeRelativeToProject "Hledger/Cli/Commands/Close.md" >>= hereFileExp))
[flagNone ["opening"] (\opts -> setboolopt "opening" opts) "show just opening transaction" [flagNone ["opening"] (\opts -> setboolopt "opening" opts) "show just opening transaction"
,flagNone ["closing"] (\opts -> setboolopt "closing" opts) "show just closing transaction" ,flagNone ["closing"] (\opts -> setboolopt "closing" opts) "show just closing transaction"
] ]

View File

@ -9,6 +9,7 @@ Hledger.Utils.
module Hledger.Cli.Utils module Hledger.Cli.Utils
( (
hereFileRelativeToPackage,
withJournalDo, withJournalDo,
writeOutput, writeOutput,
journalTransform, journalTransform,
@ -31,12 +32,16 @@ import Control.Exception as C
import Control.Monad import Control.Monad
import Data.Hashable (hash) import Data.Hashable (hash)
import Data.FileEmbed (makeRelativeToProject)
import Data.List import Data.List
import Data.Maybe import Data.Maybe
import qualified Data.Text as T import qualified Data.Text as T
import qualified Data.Text.IO as T import qualified Data.Text.IO as T
import Data.String.Here (hereFile)
import Data.Time (Day, addDays) import Data.Time (Day, addDays)
import Data.Word import Data.Word
import Language.Haskell.TH.Quote (QuasiQuoter(..))
import Language.Haskell.TH.Syntax (Q, Exp)
import Numeric import Numeric
import Safe (readMay) import Safe (readMay)
import System.Console.CmdArgs import System.Console.CmdArgs
@ -58,6 +63,13 @@ import Hledger.Read
import Hledger.Reports import Hledger.Reports
import Hledger.Utils import Hledger.Utils
-- XXX hereFile or embedFile ? QQ or TH ? does it matter ?
-- | Embed the contents of a file, given a path relative to the current package.
hereFileRelativeToPackage :: FilePath -> Q Exp
hereFileRelativeToPackage f = makeRelativeToProject f >>= hereFileExp
where
QuasiQuoter{quoteExp=hereFileExp} = hereFile
-- | Parse the user's specified journal file(s) as a Journal, maybe apply some -- | Parse the user's specified journal file(s) as a Journal, maybe apply some
-- transformations according to options, and run a hledger command with it. -- transformations according to options, and run a hledger command with it.
-- Or, throw an error. -- Or, throw an error.

View File

@ -4,7 +4,7 @@ cabal-version: 1.12
-- --
-- see: https://github.com/sol/hpack -- see: https://github.com/sol/hpack
-- --
-- hash: 5e004994f6f3f961edee83542d3b428dc7eb7cb365b32822b513b988c351f697 -- hash: 725d6fac0dd1253d2b6f12ee2384d62f9204cae3c8a553906084b771b364861c
name: hledger name: hledger
version: 1.12.99 version: 1.12.99
@ -145,6 +145,7 @@ library
, shakespeare >=2.0.2.2 , shakespeare >=2.0.2.2
, split >=0.1 , split >=0.1
, tabular >=0.2 , tabular >=0.2
, template-haskell
, temporary , temporary
, text >=0.11 , text >=0.11
, time >=1.5 , time >=1.5
@ -196,6 +197,7 @@ executable hledger
, shakespeare >=2.0.2.2 , shakespeare >=2.0.2.2
, split >=0.1 , split >=0.1
, tabular >=0.2 , tabular >=0.2
, template-haskell
, temporary , temporary
, text >=0.11 , text >=0.11
, time >=1.5 , time >=1.5
@ -250,6 +252,7 @@ test-suite test
, shakespeare >=2.0.2.2 , shakespeare >=2.0.2.2
, split >=0.1 , split >=0.1
, tabular >=0.2 , tabular >=0.2
, template-haskell
, temporary , temporary
, test-framework , test-framework
, test-framework-hunit , test-framework-hunit
@ -305,6 +308,7 @@ benchmark bench
, shakespeare >=2.0.2.2 , shakespeare >=2.0.2.2
, split >=0.1 , split >=0.1
, tabular >=0.2 , tabular >=0.2
, template-haskell
, temporary , temporary
, text >=0.11 , text >=0.11
, time >=1.5 , time >=1.5

View File

@ -104,6 +104,7 @@ dependencies:
- safe >=0.2 - safe >=0.2
- shakespeare >=2.0.2.2 - shakespeare >=2.0.2.2
- split >=0.1 - split >=0.1
- template-haskell
- math-functions >=0.2.0.0 - math-functions >=0.2.0.0
- tabular >=0.2 - tabular >=0.2
- temporary - temporary