2013-09-20 20:38:54 +04:00
|
|
|
#!/usr/bin/env runhaskell
|
|
|
|
{-|
|
|
|
|
hledger-print-unique [-f JOURNALFILE | -f-]
|
|
|
|
|
|
|
|
Print only journal entries which are unique by description (or
|
|
|
|
something else). Reads the default or specified journal, or stdin.
|
|
|
|
|
|
|
|
|-}
|
|
|
|
|
|
|
|
import Data.List
|
|
|
|
import Data.Ord
|
|
|
|
import Hledger.Cli
|
|
|
|
|
|
|
|
main = do
|
2013-12-14 07:10:54 +04:00
|
|
|
putStrLn "(-f option not supported)"
|
2013-09-23 09:31:06 +04:00
|
|
|
opts <- getCliOpts (defCommandMode ["hledger-print-unique"])
|
2013-09-20 20:38:54 +04:00
|
|
|
withJournalDo opts $
|
|
|
|
\opts j@Journal{jtxns=ts} -> print' opts j{jtxns=uniquify ts}
|
2014-09-11 00:07:53 +04:00
|
|
|
where
|
2013-09-20 20:38:54 +04:00
|
|
|
uniquify = nubBy (\t1 t2 -> thingToCompare t1 == thingToCompare t2) . sortBy (comparing thingToCompare)
|
2013-09-23 09:31:06 +04:00
|
|
|
thingToCompare = tdescription
|
|
|
|
-- thingToCompare = tdate
|