stop depending on here due to slow haskell-src-meta/stackage issues

Using file-embed or ordinary literals instead, for now.
This commit is contained in:
Simon Michael 2019-02-02 16:34:10 -08:00
parent e1622bcca6
commit 86d5652e53
30 changed files with 111 additions and 121 deletions

View File

@ -37,18 +37,18 @@ where
import Control.Monad (liftM, when)
-- import Data.Char
import Data.Default
import Data.FileEmbed (makeRelativeToProject, embedFile)
import Data.FileEmbed (makeRelativeToProject, embedStringFile)
import Data.List
-- import Data.Maybe
-- import Data.PPrint
import Data.String.Here (hereFile)
-- import Data.String.Here (hereFile)
import Data.Text (Text)
import qualified Data.Text.IO as T
import Data.Time.Clock
import Data.Time.LocalTime
-- import Data.Text (Text)
-- import qualified Data.Text as T
import Language.Haskell.TH.Quote (QuasiQuoter(..))
-- import Language.Haskell.TH.Quote (QuasiQuoter(..))
import Language.Haskell.TH.Syntax (Q, Exp)
import System.Directory (getHomeDirectory)
import System.FilePath((</>), isRelative)
@ -225,16 +225,16 @@ mapM' :: Monad f => (a -> f b) -> [a] -> f [b]
mapM' f = sequence' . map f
-- | Like embedFile, but takes a path relative to the package directory.
-- Similar to hereFileRelative ?
embedFileRelative :: FilePath -> Q Exp
embedFileRelative f = makeRelativeToProject f >>= embedFile
-- | Like hereFile, but takes a path relative to the package directory.
-- Similar to embedFileRelative ?
hereFileRelative :: FilePath -> Q Exp
hereFileRelative f = makeRelativeToProject f >>= hereFileExp
where
QuasiQuoter{quoteExp=hereFileExp} = hereFile
embedFileRelative :: FilePath -> Q Exp
embedFileRelative f = makeRelativeToProject f >>= embedStringFile
-- -- | Like hereFile, but takes a path relative to the package directory.
-- -- Similar to embedFileRelative ?
-- hereFileRelative :: FilePath -> Q Exp
-- hereFileRelative f = makeRelativeToProject f >>= hereFileExp
-- where
-- QuasiQuoter{quoteExp=hereFileExp} = hereFile
tests_Utils = tests "Utils" [
tests_Text

View File

@ -4,7 +4,7 @@ cabal-version: 1.12
--
-- see: https://github.com/sol/hpack
--
-- hash: c17b44c345a89a13650ca3efcba7d7e8311e9312acfd08dff5f2716e70ca29d7
-- hash: 25ebf00dbf3312c8ce9cef75a4e0dbc04608eca66a179fb6fdc92d9d5e1c3b54
name: hledger-lib
version: 1.13
@ -124,7 +124,6 @@ library
, file-embed >=0.0.10
, filepath
, hashtables >=1.2.3.1
, here
, megaparsec >=7.0.0 && <8
, mtl
, mtl-compat
@ -227,7 +226,6 @@ test-suite doctests
, file-embed >=0.0.10
, filepath
, hashtables >=1.2.3.1
, here
, megaparsec >=7.0.0 && <8
, mtl
, mtl-compat
@ -329,7 +327,6 @@ test-suite easytests
, file-embed >=0.0.10
, filepath
, hashtables >=1.2.3.1
, here
, hledger-lib
, megaparsec >=7.0.0 && <8
, mtl

View File

@ -58,7 +58,6 @@ dependencies:
- file-embed >=0.0.10
- filepath
- hashtables >=1.2.3.1
- here
- megaparsec >=7.0.0 && <8
- mtl
- mtl-compat

View File

@ -47,7 +47,6 @@ import Data.List
#if !(MIN_VERSION_base(4,11,0))
import Data.Monoid ((<>))
#endif
import Data.String.Here
import Data.Text (Text)
import qualified Data.Text as T
import Data.Time.Calendar
@ -132,63 +131,63 @@ builtinCommands = [
-- TODO: generate more of this automatically.
--
commandsList :: String
commandsList = [here|
-------------------------------------------------------------------------------
PROGVERSION
Usage: hledger COMMAND [OPTIONS] [-- ADDONCMDOPTIONS]
Commands (+ addons found in $PATH):
Data entry (these commands modify the journal file):
add add transactions using guided prompts
+iadd add transactions using curses ui
import add any new transactions from other files (eg csv)
Data management:
+autosync download/deduplicate/convert OFX data
+check check more powerful balance assertions
check-dates check transactions are ordered by date
check-dupes check for accounts with the same leaf name
close (equity) generate balance-resetting transactions
+diff compare account transactions in two journal files
+interest generate interest transactions
rewrite generate automated postings/diffs (old, use --auto)
Financial reports:
balancesheet (bs) show assets, liabilities and net worth
balancesheetequity (bse) show assets, liabilities and equity
cashflow (cf) show changes in liquid assets
incomestatement (is) show revenues and expenses
+irr calculate internal rate of return (old, use roi)
roi show return on investments
Low-level reports:
accounts (a) show account names
activity show postings-per-interval bar charts
balance (b, bal) show balance changes/end balances/budgets in accounts
files show input file paths
prices show market price records
print (p, txns) show transactions (journal entries)
print-unique show only transactions with unique descriptions
register (r, reg) show postings in one or more accounts & running total
register-match show a recent posting that best matches a description
stats show journal statistics
tags show tag names
test run self tests
Alternate user interfaces:
+ui run curses ui
+web run web ui
+api run http api server
Other:
OTHER
Help:
(no arguments) show this commands list
-h show general flags
COMMAND -h show flags & docs for COMMAND
help [MANUAL] show hledger manuals in various formats
|]
commandsList = unlines [
"-------------------------------------------------------------------------------"
,"PROGVERSION"
,"Usage: hledger COMMAND [OPTIONS] [-- ADDONCMDOPTIONS]"
,"Commands (+ addons found in $PATH):"
,""
,"Data entry (these commands modify the journal file):"
," add add transactions using guided prompts"
,"+iadd add transactions using curses ui"
," import add any new transactions from other files (eg csv)"
,""
,"Data management:"
,"+autosync download/deduplicate/convert OFX data"
,"+check check more powerful balance assertions"
," check-dates check transactions are ordered by date"
," check-dupes check for accounts with the same leaf name"
," close (equity) generate balance-resetting transactions"
,"+diff compare account transactions in two journal files"
,"+interest generate interest transactions"
," rewrite generate automated postings/diffs (old, use --auto)"
,""
,"Financial reports:"
," balancesheet (bs) show assets, liabilities and net worth"
," balancesheetequity (bse) show assets, liabilities and equity"
," cashflow (cf) show changes in liquid assets"
," incomestatement (is) show revenues and expenses"
,"+irr calculate internal rate of return (old, use roi)"
," roi show return on investments"
,""
,"Low-level reports:"
," accounts (a) show account names"
," activity show postings-per-interval bar charts"
," balance (b, bal) show balance changes/end balances/budgets in accounts"
," files show input file paths"
," prices show market price records"
," print (p, txns) show transactions (journal entries)"
," print-unique show only transactions with unique descriptions"
," register (r, reg) show postings in one or more accounts & running total"
," register-match show a recent posting that best matches a description"
," stats show journal statistics"
," tags show tag names"
," test run self tests"
,""
,"Alternate user interfaces:"
,"+ui run curses ui"
,"+web run web ui"
,"+api run http api server"
,""
,"Other:"
,"OTHER"
,"Help:"
," (no arguments) show this commands list"
," -h show general flags"
," COMMAND -h show flags & docs for COMMAND"
," help [MANUAL] show hledger manuals in various formats"
,""
]
-- commands show brief commands list
-- edit open a text editor on some part of the journal
-- aregister (ar, areg) show transactions in a single account
@ -236,7 +235,7 @@ printCommandsList addonsFound =
-- The test command is defined here for easy access to other modules' tests.
testmode = hledgerCommandMode
$(hereFileRelative "Hledger/Cli/Commands/Test.txt")
$(embedFileRelative "Hledger/Cli/Commands/Test.txt")
[]
[generalflagsgroup3]
[]

View File

@ -35,7 +35,7 @@ import Hledger.Cli.CliOptions
-- | Command line options for this command.
accountsmode = hledgerCommandMode
$(hereFileRelative "Hledger/Cli/Commands/Accounts.txt")
$(embedFileRelative "Hledger/Cli/Commands/Accounts.txt")
[flagNone ["declared"] (\opts -> setboolopt "declared" opts) "show account names declared with account directives"
,flagNone ["used"] (\opts -> setboolopt "used" opts) "show account names referenced by transactions"
,flagNone ["tree"] (\opts -> setboolopt "tree" opts) "show short account names, as a tree"

View File

@ -20,7 +20,7 @@ import Prelude hiding (putStr)
import Hledger.Utils.UTF8IOCompat (putStr)
activitymode = hledgerCommandMode
$(hereFileRelative "Hledger/Cli/Commands/Activity.txt")
$(embedFileRelative "Hledger/Cli/Commands/Activity.txt")
[]
[generalflagsgroup1]
[]

View File

@ -48,7 +48,7 @@ import Hledger.Cli.Commands.Register (postingsReportAsText)
addmode = hledgerCommandMode
$(hereFileRelative "Hledger/Cli/Commands/Add.txt")
$(embedFileRelative "Hledger/Cli/Commands/Add.txt")
[flagNone ["no-new-accounts"] (\opts -> setboolopt "no-new-accounts" opts) "don't allow creating new accounts"]
[generalflagsgroup2]
[]

View File

@ -270,7 +270,7 @@ import Hledger.Read.CsvReader (CSV, printCSV)
-- | Command line options for this command.
balancemode = hledgerCommandMode
$(hereFileRelative "Hledger/Cli/Commands/Balance.txt")
$(embedFileRelative "Hledger/Cli/Commands/Balance.txt")
([flagNone ["change"] (\opts -> setboolopt "change" opts)
"show balance change in each period (default)"
,flagNone ["cumulative"] (\opts -> setboolopt "cumulative" opts)

View File

@ -18,7 +18,7 @@ import Hledger.Cli.CliOptions
import Hledger.Cli.CompoundBalanceCommand
balancesheetSpec = CompoundBalanceCommandSpec {
cbcdoc = ($(hereFileRelative "Hledger/Cli/Commands/Balancesheet.txt")),
cbcdoc = ($(embedFileRelative "Hledger/Cli/Commands/Balancesheet.txt")),
cbctitle = "Balance Sheet",
cbcqueries = [
CBCSubreportSpec{

View File

@ -18,7 +18,7 @@ import Hledger.Cli.CliOptions
import Hledger.Cli.CompoundBalanceCommand
balancesheetequitySpec = CompoundBalanceCommandSpec {
cbcdoc = ($(hereFileRelative "Hledger/Cli/Commands/Balancesheetequity.txt")),
cbcdoc = ($(embedFileRelative "Hledger/Cli/Commands/Balancesheetequity.txt")),
cbctitle = "Balance Sheet With Equity",
cbcqueries = [
CBCSubreportSpec{

View File

@ -21,7 +21,7 @@ import Hledger.Cli.CliOptions
import Hledger.Cli.CompoundBalanceCommand
cashflowSpec = CompoundBalanceCommandSpec {
cbcdoc = ($(hereFileRelative "Hledger/Cli/Commands/Cashflow.txt")),
cbcdoc = ($(embedFileRelative "Hledger/Cli/Commands/Cashflow.txt")),
cbctitle = "Cashflow Statement",
cbcqueries = [
CBCSubreportSpec{

View File

@ -13,7 +13,7 @@ import Text.Printf
checkdatesmode :: Mode RawOpts
checkdatesmode = hledgerCommandMode
($(hereFileRelative "Hledger/Cli/Commands/Checkdates.txt"))
($(embedFileRelative "Hledger/Cli/Commands/Checkdates.txt"))
[flagNone ["strict"] (\opts -> setboolopt "strict" opts) "makes date comparing strict"]
[generalflagsgroup1]
[]

View File

@ -16,7 +16,7 @@ import Text.Printf
checkdupesmode :: Mode RawOpts
checkdupesmode = hledgerCommandMode
($(hereFileRelative "Hledger/Cli/Commands/Checkdupes.txt"))
($(embedFileRelative "Hledger/Cli/Commands/Checkdupes.txt"))
[]
[generalflagsgroup1]
[]

View File

@ -16,7 +16,7 @@ import Hledger
import Hledger.Cli.CliOptions
closemode = hledgerCommandMode
$(hereFileRelative "Hledger/Cli/Commands/Close.txt")
$(embedFileRelative "Hledger/Cli/Commands/Close.txt")
[flagNone ["opening"] (\opts -> setboolopt "opening" opts) "show just opening transaction"
,flagNone ["closing"] (\opts -> setboolopt "closing" opts) "show just closing transaction"
]

View File

@ -23,7 +23,7 @@ import Hledger.Cli.CliOptions
-- | Command line options for this command.
filesmode = hledgerCommandMode
($(hereFileRelative "Hledger/Cli/Commands/Files.txt"))
($(embedFileRelative "Hledger/Cli/Commands/Files.txt"))
[]
[generalflagsgroup2]
[]

View File

@ -20,7 +20,6 @@ module Hledger.Cli.Commands.Help (
import Prelude ()
import "base-compat-batteries" Prelude.Compat
import Data.Char
import Data.String.Here
import Data.List
import Data.Maybe
import Safe
@ -28,7 +27,7 @@ import System.Console.CmdArgs.Explicit
import System.Environment
import System.IO
import Hledger.Utils (hereFileRelative)
import Hledger.Utils (embedFileRelative)
import Hledger.Data.RawOptions
import Hledger.Data.Types
import Hledger.Cli.CliOptions
@ -36,7 +35,7 @@ import Hledger.Cli.DocFiles
--import Hledger.Utils.Debug
helpmode = hledgerCommandMode
($(hereFileRelative "Hledger/Cli/Commands/Help.txt"))
($(embedFileRelative "Hledger/Cli/Commands/Help.txt"))
[flagNone ["info"] (setboolopt "info") "show the manual with info"
,flagNone ["man"] (setboolopt "man") "show the manual with man"
,flagNone ["pager"] (setboolopt "pager") "show the manual with $PAGER or less"
@ -74,9 +73,10 @@ help' opts _ = do
| pagerprog `elem` exes = pager
| otherwise = cat
case topic of
Nothing -> putStrLn $ [here|
Please choose a manual by typing "hledger help MANUAL" (any substring is ok).
A viewer (info, man, a pager, or stdout) will be auto-selected,
or type "hledger help -h" to see options. Manuals available:
|] ++ "\n " ++ intercalate " " docTopics
Nothing -> putStrLn $ unlines [
"Please choose a manual by typing \"hledger help MANUAL\" (any substring is ok)."
,"A viewer (info, man, a pager, or stdout) will be auto-selected,"
,"or type \"hledger help -h\" to see options. Manuals available:"
]
++ "\n " ++ intercalate " " docTopics
Just t -> viewer t

View File

@ -18,7 +18,7 @@ import System.Console.CmdArgs.Explicit
import Text.Printf
importmode = hledgerCommandMode
($(hereFileRelative "Hledger/Cli/Commands/Import.txt"))
($(embedFileRelative "Hledger/Cli/Commands/Import.txt"))
[flagNone ["dry-run"] (\opts -> setboolopt "dry-run" opts) "just show the transactions to be imported"]
[generalflagsgroup1]
[]

View File

@ -17,7 +17,7 @@ import Hledger.Cli.CliOptions
import Hledger.Cli.CompoundBalanceCommand
incomestatementSpec = CompoundBalanceCommandSpec {
cbcdoc = ($(hereFileRelative "Hledger/Cli/Commands/Incomestatement.txt")),
cbcdoc = ($(embedFileRelative "Hledger/Cli/Commands/Incomestatement.txt")),
cbctitle = "Income Statement",
cbcqueries = [
CBCSubreportSpec{

View File

@ -15,7 +15,7 @@ import Hledger.Cli.CliOptions
import System.Console.CmdArgs.Explicit
pricesmode = hledgerCommandMode
($(hereFileRelative "Hledger/Cli/Commands/Prices.txt"))
($(embedFileRelative "Hledger/Cli/Commands/Prices.txt"))
[flagNone ["costs"] (setboolopt "costs") "print transaction prices from postings"
,flagNone ["inverted-costs"] (setboolopt "inverted-costs") "print transaction inverted prices from postings also"]
[generalflagsgroup1]

View File

@ -27,7 +27,7 @@ import Hledger.Cli.Commands.Add ( transactionsSimilarTo )
printmode = hledgerCommandMode
($(hereFileRelative "Hledger/Cli/Commands/Print.txt"))
($(embedFileRelative "Hledger/Cli/Commands/Print.txt"))
[let arg = "STR" in
flagReq ["match","m"] (\s opts -> Right $ setopt "match" s opts) arg
("show the transaction whose description is most similar to "++arg++", and is most recent")

View File

@ -13,7 +13,7 @@ import Hledger.Cli.CliOptions
import Hledger.Cli.Commands.Print
printuniquemode = hledgerCommandMode
($(hereFileRelative "Hledger/Cli/Commands/Printunique.txt"))
($(embedFileRelative "Hledger/Cli/Commands/Printunique.txt"))
[]
[generalflagsgroup1]
[]

View File

@ -28,7 +28,7 @@ import Hledger.Cli.CliOptions
import Hledger.Cli.Utils
registermode = hledgerCommandMode
($(hereFileRelative "Hledger/Cli/Commands/Register.txt"))
($(embedFileRelative "Hledger/Cli/Commands/Register.txt"))
[flagNone ["cumulative"] (\opts -> setboolopt "change" opts)
"show running total from report start date (default)"
,flagNone ["historical","H"] (\opts -> setboolopt "historical" opts)

View File

@ -15,7 +15,7 @@ import Hledger.Cli.CliOptions
import Hledger.Cli.Commands.Register
registermatchmode = hledgerCommandMode
($(hereFileRelative "Hledger/Cli/Commands/Registermatch.txt"))
($(embedFileRelative "Hledger/Cli/Commands/Registermatch.txt"))
[]
[generalflagsgroup1]
[]

View File

@ -23,7 +23,7 @@ import Text.Megaparsec
import qualified Data.Algorithm.Diff as D
rewritemode = hledgerCommandMode
($(hereFileRelative "Hledger/Cli/Commands/Rewrite.txt"))
($(embedFileRelative "Hledger/Cli/Commands/Rewrite.txt"))
[flagReq ["add-posting"] (\s opts -> Right $ setopt "add-posting" s opts) "'ACCT AMTEXPR'"
"add a posting to ACCT, which may be parenthesised. AMTEXPR is either a literal amount, or *N which means the transaction's first matched amount multiplied by N (a decimal number). Two spaces separate ACCT and AMTEXPR."
,flagNone ["diff"] (setboolopt "diff") "generate diff suitable as an input for patch tool"

View File

@ -30,7 +30,7 @@ import Hledger.Cli.CliOptions
roimode = hledgerCommandMode
($(hereFileRelative "Hledger/Cli/Commands/Roi.txt"))
($(embedFileRelative "Hledger/Cli/Commands/Roi.txt"))
[flagNone ["cashflow"] (setboolopt "cashflow") "show all amounts that were used to compute returns"
,flagReq ["investment"] (\s opts -> Right $ setopt "investment" s opts) "QUERY"
"query to select your investment transactions"

View File

@ -31,7 +31,7 @@ import Hledger.Cli.Utils (writeOutput)
statsmode = hledgerCommandMode
($(hereFileRelative "Hledger/Cli/Commands/Stats.txt"))
($(embedFileRelative "Hledger/Cli/Commands/Stats.txt"))
[flagReq ["output-file","o"] (\s opts -> Right $ setopt "output-file" s opts) "FILE" "write output to FILE. A file extension matching one of the above formats selects that format."
]
[generalflagsgroup1]

View File

@ -14,7 +14,7 @@ import Hledger
import Hledger.Cli.CliOptions
tagsmode = hledgerCommandMode
($(hereFileRelative "Hledger/Cli/Commands/Tags.txt"))
($(embedFileRelative "Hledger/Cli/Commands/Tags.txt"))
[] -- [flagNone ["strict"] (\opts -> setboolopt "strict" opts) "makes date comparing strict"] --
[generalflagsgroup1]
[]

View File

@ -42,7 +42,6 @@ module Hledger.Cli.Main where
import Data.Char (isDigit)
import Data.List
import Data.String.Here
import Safe
import System.Console.CmdArgs.Explicit as C
import System.Environment
@ -83,14 +82,15 @@ mainmode addons = defMode {
[detailedversionflag]
-- ++ inputflags -- included here so they'll not raise a confusing error if present with no COMMAND
}
,modeHelpSuffix = lines $ regexReplace "PROGNAME" progname [here|Examples:
PROGNAME list commands
PROGNAME CMD [--] [OPTS] [ARGS] run a command (use -- with addon commands)
PROGNAME-CMD [OPTS] [ARGS] or run addon commands directly
PROGNAME -h show general usage
PROGNAME CMD -h show command usage
PROGNAME help [MANUAL] show any of the hledger manuals in various formats
|]
,modeHelpSuffix = map (regexReplace "PROGNAME" progname) [
"Examples:"
,"PROGNAME list commands"
,"PROGNAME CMD [--] [OPTS] [ARGS] run a command (use -- with addon commands)"
,"PROGNAME-CMD [OPTS] [ARGS] or run addon commands directly"
,"PROGNAME -h show general usage"
,"PROGNAME CMD -h show command usage"
,"PROGNAME help [MANUAL] show any of the hledger manuals in various formats"
]
}
-- | Let's go!

View File

@ -4,7 +4,7 @@ cabal-version: 1.12
--
-- see: https://github.com/sol/hpack
--
-- hash: 0f31726cb805b74d59400bb1d7502bb6c6c7f01eb41ac0272c4da6a8d94144b2
-- hash: 23ad53c1065d2d491ad11197683363d92136d6117de4ea6cc258865b82b5fc52
name: hledger
version: 1.13
@ -152,7 +152,6 @@ library
, filepath
, hashable >=1.2.4
, haskeline >=0.6
, here
, hledger-lib >=1.13 && <1.14
, lucid
, math-functions >=0.2.0.0
@ -202,7 +201,6 @@ executable hledger
, easytest
, filepath
, haskeline >=0.6
, here
, hledger
, hledger-lib >=1.13 && <1.14
, math-functions >=0.2.0.0
@ -255,7 +253,6 @@ test-suite test
, easytest
, filepath
, haskeline >=0.6
, here
, hledger
, hledger-lib >=1.13 && <1.14
, math-functions >=0.2.0.0
@ -308,7 +305,6 @@ benchmark bench
, easytest
, filepath
, haskeline >=0.6
, here
, hledger
, hledger-lib >=1.13 && <1.14
, html

View File

@ -116,7 +116,6 @@ dependencies:
- easytest
- filepath
- haskeline >=0.6
- here
- megaparsec >=7.0.0 && <8
- mtl
- mtl-compat