mirror of
https://github.com/simonmichael/hledger.git
synced 2024-11-10 05:39:31 +03:00
register command cleanups
This commit is contained in:
parent
b542da133c
commit
2dc44cb131
@ -46,15 +46,13 @@ registermode = (defCommandMode $ ["register"] ++ aliases) {
|
|||||||
register :: CliOpts -> Journal -> IO ()
|
register :: CliOpts -> Journal -> IO ()
|
||||||
register opts@CliOpts{reportopts_=ropts} j = do
|
register opts@CliOpts{reportopts_=ropts} j = do
|
||||||
d <- getCurrentDay
|
d <- getCurrentDay
|
||||||
let r = postingsReport ropts (queryFromOpts d ropts) j
|
|
||||||
|
|
||||||
(path, ext) <- outputFilePathAndExtensionFromOpts opts
|
(path, ext) <- outputFilePathAndExtensionFromOpts opts
|
||||||
let filename = fst $ splitExtension $ snd $ splitFileName path
|
let filename = fst $ splitExtension $ snd $ splitFileName path
|
||||||
write | filename `elem` ["","-"] && ext `elem` ["","csv","txt"] = putStr
|
write | filename `elem` ["","-"] && ext `elem` ["","csv","txt"] = putStr
|
||||||
| otherwise = writeFile path
|
| otherwise = writeFile path
|
||||||
render | ext=="csv" = \_ r -> (printCSV . postingsReportAsCsv) r
|
render | ext=="csv" = const ((++"\n") . printCSV . postingsReportAsCsv)
|
||||||
| otherwise = postingsReportAsText
|
| otherwise = postingsReportAsText
|
||||||
write $ render opts r
|
write $ render opts $ postingsReport ropts (queryFromOpts d ropts) j
|
||||||
|
|
||||||
postingsReportAsCsv :: PostingsReport -> CSV
|
postingsReportAsCsv :: PostingsReport -> CSV
|
||||||
postingsReportAsCsv (_,is) =
|
postingsReportAsCsv (_,is) =
|
||||||
|
Loading…
Reference in New Issue
Block a user