hledger 0.18 → 0.18.1
raw patch · 4 files changed
+25/−25 lines, 4 filesdep ~hledger-libPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: hledger-lib
API changes (from Hackage documentation)
- Hledger.Cli.Options: rulesFilePathFromOpts :: CliOpts -> Maybe FilePath
+ Hledger.Cli.Options: rulesFilePathFromOpts :: CliOpts -> IO (Maybe FilePath)
Files
- Hledger/Cli/Options.hs +8/−15
- Hledger/Cli/Stats.hs +10/−5
- Hledger/Cli/Utils.hs +4/−2
- hledger.cabal +3/−3
Hledger/Cli/Options.hs view
@@ -456,25 +456,18 @@ , FormatField True Nothing Nothing AccountField ] --- | Get the journal file path from options, an environment variable, or a default.--- If the path contains a literal tilde raise an error to avoid confusion. XXX+-- | Get the (tilde-expanded, absolute) journal file path from options, an environment variable, or a default. journalFilePathFromOpts :: CliOpts -> IO String journalFilePathFromOpts opts = do f <- defaultJournalPath- let f' = fromMaybe f $ file_ opts- if '~' `elem` f'- then error' $ printf "~ in the journal file path is not supported, please adjust (%s)" f'- else return f'+ d <- getCurrentDirectory+ expandPath d $ fromMaybe f $ file_ opts --- | Get the rules file path from options, if any.--- If the path contains a literal tilde raise an error to avoid confusion. XXX-rulesFilePathFromOpts :: CliOpts -> Maybe FilePath-rulesFilePathFromOpts opts =- case rules_file_ opts of- Nothing -> Nothing- Just f -> if '~' `elem` f- then error' $ printf "~ in file paths is not supported, please adjust (%s)" f- else Just f+-- | Get the (tilde-expanded) rules file path from options, if any.+rulesFilePathFromOpts :: CliOpts -> IO (Maybe FilePath)+rulesFilePathFromOpts opts = do+ d <- getCurrentDirectory+ maybe (return Nothing) (fmap Just . expandPath d) $ rules_file_ opts aliasesFromOpts :: CliOpts -> [(AccountName,AccountName)] aliasesFromOpts = map parseAlias . alias_
Hledger/Cli/Stats.hs view
@@ -34,13 +34,16 @@ showLedgerStats :: Ledger -> Day -> DateSpan -> String showLedgerStats l today span =- unlines (map (uncurry (printf fmt)) stats)+ unlines $ map (\(label,value) -> concatBottomPadded [printf fmt1 label, value]) stats where- fmt = "%-" ++ show w1 ++ "s: %-" ++ show w2 ++ "s"+ fmt1 = "%-" ++ show w1 ++ "s: "+ -- fmt2 = "%-" ++ show w2 ++ "s" w1 = maximum $ map (length . fst) stats- w2 = maximum $ map (length . show . snd) stats+ -- w2 = maximum $ map (length . show . snd) stats stats = [- ("Journal file", journalFilePath $ ledgerJournal l)+ ("Main journal file", path) -- ++ " (from " ++ source ++ ")")+ ,("Included journal files", unlines $ reverse $ -- cf journalAddFile+ drop 1 $ journalFilePaths j) ,("Transactions span", printf "%s to %s (%d days)" (start span) (end span) days) ,("Last transaction", maybe "none" show lastdate ++ showelapsed lastelapsed) ,("Transactions", printf "%d (%0.1f per day)" tnum txnrate)@@ -55,7 +58,9 @@ -- Days since last transaction : %(recentelapsed)s ] where- ts = sortBy (comparing tdate) $ filter (spanContainsDate span . tdate) $ jtxns $ ledgerJournal l+ j = ledgerJournal l+ path = journalFilePath j+ ts = sortBy (comparing tdate) $ filter (spanContainsDate span . tdate) $ jtxns j as = nub $ map paccount $ concatMap tpostings ts cs = Map.keys $ canonicaliseCommodities $ nub $ map commodity $ concatMap amounts $ map pamount $ concatMap tpostings ts lastdate | null ts = Nothing
Hledger/Cli/Utils.hs view
@@ -48,8 +48,10 @@ -- We kludgily read the file before parsing to grab the full text, unless -- it's stdin, or it doesn't exist and we are adding. We read it strictly -- to let the add command work.- journalFilePathFromOpts opts >>= readJournalFile Nothing (rulesFilePathFromOpts opts) >>=- either error' (cmd opts . journalApplyAliases (aliasesFromOpts opts))+ rulespath <- rulesFilePathFromOpts opts+ journalpath <- journalFilePathFromOpts opts+ ej <- readJournalFile Nothing rulespath journalpath+ either error' (cmd opts . journalApplyAliases (aliasesFromOpts opts)) ej -- -- | Get a journal from the given string and options, or throw an error. -- readJournalWithOpts :: CliOpts -> String -> IO Journal
hledger.cabal view
@@ -1,5 +1,5 @@ name: hledger-version: 0.18+version: 0.18.1 category: Finance synopsis: The main command-line interface for the hledger accounting tool. description:@@ -62,7 +62,7 @@ Hledger.Cli.Stats -- should be the same as below build-depends:- hledger-lib == 0.18+ hledger-lib == 0.18.1 ,base >= 3 && < 5 ,cabal-file-th ,containers@@ -117,7 +117,7 @@ ghc-options: -threaded -- should be the same as above build-depends:- hledger-lib == 0.18+ hledger-lib == 0.18.1 ,base >= 3 && < 5 ,cabal-file-th ,containers