packages feed

hledger-flow 0.16.3 → 0.16.4

raw patch · 9 files changed

+56/−21 lines, 9 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

+ Hledger.Flow.Common: hledgerConfArgs :: RuntimeOptions -> [Text]
+ Hledger.Flow.RuntimeOptions: [hledgerConf] :: RuntimeOptions -> Maybe TurtlePath
- Hledger.Flow.RuntimeOptions: RuntimeOptions :: BaseDir -> RunDir -> Maybe Integer -> Bool -> Text -> HledgerInfo -> SystemInfo -> Bool -> Bool -> Bool -> Int -> Bool -> RuntimeOptions
+ Hledger.Flow.RuntimeOptions: RuntimeOptions :: BaseDir -> RunDir -> Maybe Integer -> Bool -> Text -> HledgerInfo -> Maybe TurtlePath -> SystemInfo -> Bool -> Bool -> Bool -> Int -> Bool -> RuntimeOptions

Files

ChangeLog.md view
@@ -1,5 +1,11 @@ # Changelog for [hledger-flow](https://github.com/apauley/hledger-flow) +## 0.16.4++- Add a new command-line option: `--hledger-conf /path/to/hledger/conf`.+  This allows specifying a hledger config file, causing hledger-flow to pass+  `--conf /path/to/hledger/conf` to any hledger command it invokes.+ ## 0.16.3  - Change `--new-files-only` to use modification time comparison instead of existence check.
app/Main.hs view
@@ -46,6 +46,7 @@  data MainParams = MainParams { verbosity :: Int                              , hledgerPathOpt :: Maybe TurtlePath+                             , hledgerConfOpt :: Maybe TurtlePath                              , showOpts :: Bool                              , batchSize :: Maybe Int                              , sequential :: Bool@@ -85,6 +86,7 @@                            , RT.onlyNewFiles = onlyNewFiles subParams'                            , RT.hfVersion = versionInfo sysInfo                            , RT.hledgerInfo = hli+                           , RT.hledgerConf = hledgerConfOpt mainParams'                            , RT.sysInfo = sysInfo                            , RT.verbose = verbosity mainParams' > 0                            , RT.showOptions = showOpts mainParams'@@ -106,6 +108,7 @@                            , RT.onlyNewFiles = False                            , RT.hfVersion = versionInfo sysInfo                            , RT.hledgerInfo = hli+                           , RT.hledgerConf = hledgerConfOpt mainParams'                            , RT.sysInfo = sysInfo                            , RT.verbose = verbosity mainParams' > 0                            , RT.showOptions = showOpts mainParams'@@ -126,6 +129,7 @@ verboseParser = MainParams   <$> (length <$> many (flag' () (long "verbose" <> short 'v' <> help "Print more verbose output")))   <*> optional (Turtle.optPath "hledger-path" 'H' "The full path to an hledger executable")+  <*> optional (option str (long "hledger-conf" <> metavar "PATH" <> help "The hledger config file to pass to hledger --conf"))   <*> switch (long "show-options" <> help "Print the options this program will run with")   <*> optional (option auto (long "batch-size" <> metavar "SIZE" <> help ("Parallel processing of files are done in batches of the specified size. Default: " <> show defaultBatchSize <> ". Ignored during sequential processing.")))   <*> switch (long "sequential" <> help "Disable parallel processing")
hledger-flow.cabal view
@@ -1,13 +1,11 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.37.0.+-- This file has been generated from package.yaml by hpack version 0.39.6. -- -- see: https://github.com/sol/hpack------ hash: 1b63379a0d0b0c58f45cec49ae2eae3f1f4408ac97b070977ba5c1bce02f8f05  name:           hledger-flow-version:        0.16.3+version:        0.16.4 synopsis:       An hledger workflow focusing on automated statement import and classification. description:    Please see the README on GitHub at <https://github.com/apauley/hledger-flow#readme> category:       Finance, Console
src/Hledger/Flow/Common.hs view
@@ -21,6 +21,7 @@ import Hledger.Flow.BaseDir (relativeToBase, turtleBaseDir) import Hledger.Flow.Logging import Hledger.Flow.PathHelpers (AbsFile, TurtlePath, fromTurtleAbsFile, pathToTurtle)+import qualified Hledger.Flow.RuntimeOptions as RT import Hledger.Flow.Types import Path (absfile, relfile) import qualified Path.IO as Path@@ -58,6 +59,12 @@   hlp <- hledgerPathFromOption pathOption   hlv <- hledgerVersionFromPath $ pathToTurtle hlp   return $ HledgerInfo hlp hlv++hledgerConfArgs :: RT.RuntimeOptions -> [T.Text]+hledgerConfArgs opts =+  case RT.hledgerConf opts of+    Nothing -> []+    Just conf -> ["--conf", Turtle.format Turtle.fp conf]  showCmdArgs :: [T.Text] -> T.Text showCmdArgs args = T.intercalate " " (map escapeArg args)
src/Hledger/Flow/Import/CSVImport.hs view
@@ -177,7 +177,7 @@       directivesExist <- Turtle.testfile $ directivesFile opts       let directivesArgs = if directivesExist then ["--file", Turtle.format Turtle.fp (directivesFile opts)] else []       let csvArgs = ["--file", Turtle.format Turtle.fp csvSrc, "--rules-file", Turtle.format Turtle.fp rf]-      let args = ["print", "--explicit"] ++ directivesArgs ++ csvArgs+      let args = hledgerConfArgs opts ++ ["print", "--explicit"] ++ directivesArgs ++ csvArgs        let cmdLabel = Turtle.format ("importing '" % Turtle.fp % "' using rules file '" % Turtle.fp % "'") relCSV relRules       ((_, stdOut, _), _) <- timeAndExitOnErr opts ch cmdLabel dummyLogger channelErr (parAwareProc opts) (hledger, args, Turtle.empty)@@ -241,13 +241,14 @@   let stdLines = inprocWithErrFun (channelErrLn ch) (script, constructArgs, Turtle.empty)   let hledger = Turtle.format Turtle.fp $ pathToTurtle . FlowTypes.hlPath . hledgerInfo $ opts :: T.Text   let args =-        [ "print",-          "--ignore-assertions",-          "--file",-          "-",-          "--output-file",-          Turtle.format Turtle.fp journalOut-        ]+        hledgerConfArgs opts+          ++ [ "print",+               "--ignore-assertions",+               "--file",+               "-",+               "--output-file",+               Turtle.format Turtle.fp journalOut+             ]    let relSrc = relativeToBase opts csvSrc   let cmdLabel = Turtle.format ("executing '" % Turtle.fp % "' on '" % Turtle.fp % "'") relScript relSrc
src/Hledger/Flow/Reports.hs view
@@ -114,8 +114,9 @@   let outputFile = reportsDir </> fileName   let relativeJournal = relativeToBase opts journal   let relativeOutputFile = relativeToBase opts outputFile-  let reportArgs = ["--file", Turtle.format Turtle.fp journal, "--period", Turtle.repr year] ++ args-  let reportDisplayArgs = ["--file", Turtle.format Turtle.fp relativeJournal, "--period", Turtle.repr year] ++ args+  let confArgs = hledgerConfArgs opts+  let reportArgs = confArgs ++ ["--file", Turtle.format Turtle.fp journal, "--period", Turtle.repr year] ++ args+  let reportDisplayArgs = confArgs ++ ["--file", Turtle.format Turtle.fp relativeJournal, "--period", Turtle.repr year] ++ args   let hledger = Turtle.format Turtle.fp $ pathToTurtle . FlowTypes.hlPath . hledgerInfo $ opts :: T.Text   let cmdLabel = Turtle.format ("hledger " % Turtle.s) $ showCmdArgs reportDisplayArgs   ((exitCode, stdOut, _), _) <- timeAndExitOnErr opts ch cmdLabel dummyLogger channelErr Turtle.procStrictWithErr (hledger, reportArgs, mempty)
src/Hledger/Flow/RuntimeOptions.hs view
@@ -2,6 +2,7 @@  import qualified Data.Text as T import Hledger.Flow.Internals (SystemInfo)+import Hledger.Flow.PathHelpers (TurtlePath) import Hledger.Flow.Types import Prelude hiding (putStrLn) @@ -12,6 +13,7 @@     onlyNewFiles :: Bool,     hfVersion :: T.Text,     hledgerInfo :: HledgerInfo,+    hledgerConf :: Maybe TurtlePath,     sysInfo :: SystemInfo,     verbose :: Bool,     showOptions :: Bool,@@ -22,19 +24,19 @@   deriving (Show)  instance HasVerbosity RuntimeOptions where-  verbose (RuntimeOptions _ _ _ _ _ _ _ v _ _ _ _) = v+  verbose (RuntimeOptions _ _ _ _ _ _ _ _ v _ _ _ _) = v  instance HasSequential RuntimeOptions where-  sequential (RuntimeOptions _ _ _ _ _ _ _ _ _ sq _ _) = sq+  sequential (RuntimeOptions _ _ _ _ _ _ _ _ _ _ sq _ _) = sq  instance HasBatchSize RuntimeOptions where-  batchSize (RuntimeOptions _ _ _ _ _ _ _ _ _ _ bs _) = bs+  batchSize (RuntimeOptions _ _ _ _ _ _ _ _ _ _ _ bs _) = bs  instance HasBaseDir RuntimeOptions where-  baseDir (RuntimeOptions bd _ _ _ _ _ _ _ _ _ _ _) = bd+  baseDir (RuntimeOptions bd _ _ _ _ _ _ _ _ _ _ _ _) = bd  instance HasRunDir RuntimeOptions where-  importRunDir (RuntimeOptions _ rd _ _ _ _ _ _ _ _ _ _) = rd+  importRunDir (RuntimeOptions _ rd _ _ _ _ _ _ _ _ _ _ _) = rd  instance HasPrettyReports RuntimeOptions where-  prettyReports (RuntimeOptions _ _ _ _ _ _ _ _ _ _ _ pr) = pr+  prettyReports (RuntimeOptions _ _ _ _ _ _ _ _ _ _ _ _ pr) = pr
test/Common/Unit.hs view
@@ -1,13 +1,17 @@ {-# LANGUAGE OverloadedLists #-} {-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE QuasiQuotes #-}  module Common.Unit where  import Hledger.Flow.BaseDir (relativeToBase') import Hledger.Flow.Common+import Hledger.Flow.RuntimeOptions (RuntimeOptions (hledgerConf)) import qualified Data.List as List import qualified Data.Map.Strict as Map+import Path (absdir) import Test.HUnit+import TestHelpers (defaultOpts)  testShowCmdArgs :: Test testShowCmdArgs =@@ -19,6 +23,17 @@         assertEqual "Convert command-line arguments to text" expected actual     ) +testHledgerConfArgs :: Test+testHledgerConfArgs =+  TestCase+    ( do+        let optsWithoutConf = defaultOpts [absdir|/base/|]+        assertEqual "No hledger config should produce no hledger config args" [] (hledgerConfArgs optsWithoutConf)++        let optsWithConf = optsWithoutConf {hledgerConf = Just "/tmp/hledger.conf"}+        assertEqual "Configured hledger config should produce --conf args" ["--conf", "/tmp/hledger.conf"] (hledgerConfArgs optsWithConf)+    )+ testRelativeToBase :: Test testRelativeToBase =   TestCase@@ -98,4 +113,4 @@     )  tests :: Test-tests = TestList [testShowCmdArgs, testRelativeToBase, testExtractDigits, testChangePathAndExtension, testGroupValuesBy]+tests = TestList [testShowCmdArgs, testHledgerConfArgs, testRelativeToBase, testExtractDigits, testChangePathAndExtension, testGroupValuesBy]
test/TestHelpers.hs view
@@ -34,6 +34,7 @@       onlyNewFiles = False,       hfVersion = versionInfo testSystemInfo,       hledgerInfo = defaultHlInfo,+      hledgerConf = Nothing,       sysInfo = testSystemInfo,       verbose = False,       showOptions = False,