hledger-flow 0.11.3.0 → 0.12.0.0
raw patch · 5 files changed
+65/−106 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- ChangeLog.md +8/−0
- README.org +10/−66
- app/Main.hs +40/−33
- hledger-flow.cabal +2/−2
- src/Hledger/Flow/Common.hs +5/−5
ChangeLog.md view
@@ -1,5 +1,13 @@ # Changelog for [hledger-flow](https://github.com/apauley/hledger-flow) +## 0.12.0++- Re-organised the command-line interface:+ moved various command-line options out of subcommands, into the top-level.+- Added a [contributor's agreement](https://github.com/apauley/hledger-flow/blob/master/CONTRIBUTING.org)+ after receiving some more valued contributions from+ [jecaro](https://github.com/apauley/hledger-flow/pull/42)+ ## 0.11.3 - Detect the hledger-flow base directory correctly, even when in a subdirectory. Similar to how git behaves.
README.org view
@@ -47,7 +47,7 @@ for your OS, and copy the =hledger-flow= executable to a directory in your PATH. Then just run it and see what it tells you to do. -You can also compile it yourself by following the [[#build-instructions][build instructions]].+You can also compile it yourself by following the [[https://github.com/apauley/hledger-flow/blob/master/CONTRIBUTING.org#build-the-project][build instructions]]. * Overview of the Basic Workflow :PROPERTIES:@@ -113,9 +113,9 @@ Let me know if you can think of some improvements. -* Detailed Step-By-Step Guide+* Getting Started :PROPERTIES:- :CUSTOM_ID: detailed-step-by-step-guide+ :CUSTOM_ID: getting-started :END: Have a look at the [[file:docs/README.org][detailed step-by-step@@ -131,65 +131,6 @@ [[https://github.com/apauley/hledger-flow-example][https://github.com/apauley/hledger-flow-example]] -* After Cloning This Repository- :PROPERTIES:- :CUSTOM_ID: after-cloning-this-repository- :END:--This repository has some submodules included, mostly related to the-examples in the documentation.--You need to initialise and update the submodules:--#+BEGIN_SRC sh- git submodule init- git submodule update-#+END_SRC--* Build Instructions- :PROPERTIES:- :CUSTOM_ID: build-instructions- :END:--You need a recent version of [[https://docs.haskellstack.org/en/stable/README/][stack]] installed.--Then run:--#+NAME: stack-build-#+BEGIN_SRC sh :results none :exports both- stack test- stack install-#+END_SRC--Which should end with this:--#+BEGIN_SRC org- Copied executables to ~/.local/bin:- - hledger-flow-#+END_SRC--Ensure that =${HOME}/.local/bin= is in your =PATH=.--Usually this means adding this to your =~/.bashrc=:--#+BEGIN_SRC sh- PATH="${HOME}/.local/bin:${PATH}"-#+END_SRC--** Building with older Haskell Versions- :PROPERTIES:- :CUSTOM_ID: building-with-older-haskell-versions- :END:--To build using an older version of GHC and related dependencies, point-stack to one of the other yaml files:--#+NAME: stack-build-versions-#+BEGIN_SRC sh :results none :exports both- stack test --stack-yaml stack-8.4.4.yaml- stack test --stack-yaml stack-8.2.2.yaml-#+END_SRC- * Feature Reference :PROPERTIES: :CUSTOM_ID: feature-reference@@ -658,10 +599,13 @@ the way I am doing things, with as little effort as possible and without fear of irrevocably breaking things. -I've given [[https://pauley.org.za/functional-finance-hledger/][a talk]]-at-[[https://www.meetup.com/lambda-luminaries/events/qklkvpyxmbnb/][Lambda-Luminaries Johannesburg]] featuring hledger and hledger-flow.+I've given [[https://pauley.org.za/functional-finance-hledger/][a talk]] at+[[https://www.meetup.com/lambda-luminaries/events/qklkvpyxmbnb/][Lambda Luminaries Johannesburg]]+featuring hledger and hledger-flow.++* Contributing to Hledger Flow++Have a look at the [[file:CONTRIBUTING.org][contribution guidelines]]. * FAQ :PROPERTIES:
app/Main.hs view
@@ -14,52 +14,59 @@ import Hledger.Flow.Reports import Hledger.Flow.CSVImport -data SubcommandParams = SubcommandParams { maybeBaseDir :: Maybe FilePath- , hledgerPathOpt :: Maybe FilePath- , verbose :: Bool- , showOpts :: Bool- , sequential :: Bool- }- deriving (Show)-data Command = Version | Import SubcommandParams | Report SubcommandParams deriving (Show)+data SubcommandParams = SubcommandParams { maybeBaseDir :: Maybe FilePath } deriving (Show)+data Command = Import SubcommandParams | Report SubcommandParams deriving (Show) +data MainParams = MainParams { verbose :: Bool+ , hledgerPathOpt :: Maybe FilePath+ , showOpts :: Bool+ , sequential :: Bool+ } deriving (Show)+data BaseCommand = Version | Command { mainParams :: MainParams, command :: Command } deriving (Show)+ main :: IO () main = do- cmd <- options "An hledger workflow focusing on automated statement import and classification:\nhttps://github.com/apauley/hledger-flow#readme" parser+ cmd <- options "An hledger workflow focusing on automated statement import and classification:\nhttps://github.com/apauley/hledger-flow#readme" baseCommandParser case cmd of- Version -> stdout $ select versionInfo- Import subParams -> toImportOptions subParams >>= importCSVs- Report subParams -> toReportOptions subParams >>= generateReports+ Version -> stdout $ select versionInfo+ Command mainParams' (Import subParams) -> toImportOptions mainParams' subParams >>= importCSVs+ Command mainParams' (Report subParams) -> toReportOptions mainParams' subParams >>= generateReports -toImportOptions :: SubcommandParams -> IO IT.ImportOptions-toImportOptions params = do- bd <- determineBaseDir $ maybeBaseDir params- hli <- hledgerInfoFromPath $ hledgerPathOpt params+toImportOptions :: MainParams -> SubcommandParams -> IO IT.ImportOptions+toImportOptions mainParams' subParams' = do+ bd <- determineBaseDir $ maybeBaseDir subParams'+ hli <- hledgerInfoFromPath $ hledgerPathOpt mainParams' return IT.ImportOptions { IT.baseDir = bd , IT.hledgerInfo = hli- , IT.verbose = verbose params- , IT.showOptions = showOpts params- , IT.sequential = sequential params }+ , IT.verbose = verbose mainParams'+ , IT.showOptions = showOpts mainParams'+ , IT.sequential = sequential mainParams' } -toReportOptions :: SubcommandParams -> IO RT.ReportOptions-toReportOptions params = do- bd <- determineBaseDir $ maybeBaseDir params- hli <- hledgerInfoFromPath $ hledgerPathOpt params+toReportOptions :: MainParams -> SubcommandParams -> IO RT.ReportOptions+toReportOptions mainParams' subParams' = do+ bd <- determineBaseDir $ maybeBaseDir subParams'+ hli <- hledgerInfoFromPath $ hledgerPathOpt mainParams' return RT.ReportOptions { RT.baseDir = bd , RT.hledgerInfo = hli- , RT.verbose = verbose params- , RT.showOptions = showOpts params- , RT.sequential = sequential params }+ , RT.verbose = verbose mainParams'+ , RT.showOptions = showOpts mainParams'+ , RT.sequential = sequential mainParams' } -parser :: Parser Command-parser = fmap Import (subcommand "import" "Converts CSV transactions into categorised journal files" subcommandParser)- <|> fmap Report (subcommand "report" "Generate Reports" subcommandParser)+baseCommandParser :: Parser BaseCommand+baseCommandParser = (Command <$> verboseParser <*> commandParser) <|> flag' Version (long "version" <> short 'V' <> help "Display version information") -subcommandParser :: Parser SubcommandParams-subcommandParser = SubcommandParams- <$> optional (argPath "basedir" "The hledger-flow base directory")+commandParser :: Parser Command+commandParser = fmap Import (subcommand "import" "Converts electronic transactions into categorised journal files" subcommandParser)+ <|> fmap Report (subcommand "report" "Generate Reports" subcommandParser)++verboseParser :: Parser MainParams+verboseParser = MainParams+ <$> switch (long "verbose" <> short 'v' <> help "Print more verbose output") <*> optional (optPath "hledger-path" 'H' "The full path to an hledger executable")- <*> switch (long "verbose" <> short 'v' <> help "Print more verbose output") <*> switch (long "show-options" <> help "Print the options this program will run with") <*> switch (long "sequential" <> help "Disable parallel processing")++subcommandParser :: Parser SubcommandParams+subcommandParser = SubcommandParams+ <$> optional (argPath "basedir" "The hledger-flow base directory")
hledger-flow.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 2a75e18a525c30319738a863343f42c79804c552261cad30da8b396adcdab18b+-- hash: 72f9fcacd29271706ca6cfe3ac4fff4ee4706b2086e783d7ba995f4f5b6c5162 name: hledger-flow-version: 0.11.3.0+version: 0.12.0.0 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
@@ -393,10 +393,10 @@ where changeSrcDir file = if (file == "1-in/" || file == "2-preprocessed/") then newOutputLocation else file errorMessageBaseDir :: FilePath -> Text-errorMessageBaseDir startDir = format ("Unable to find an hledger-flow import directory at '"%fp+errorMessageBaseDir startDir = format ("\nUnable to find an hledger-flow import directory at '"%fp %"' (or in any of its parent directories).\n\n"- %"Have a look at the documentation for more information:\n"%s)- startDir (docURL "input-files")+ %"Have a look at the documentation for more information:\n"%s%"\n")+ startDir (docURL "getting-started") determineBaseDir :: Maybe FilePath -> IO FilePath determineBaseDir (Just suppliedDir) = determineBaseDir' suppliedDir@@ -404,8 +404,8 @@ determineBaseDir' :: FilePath -> IO FilePath determineBaseDir' startDir = do- ee <- determineBaseDir'' startDir startDir- case ee of+ ebd <- determineBaseDir'' startDir startDir+ case ebd of Right bd -> return bd Left t -> die t