hledger/hledger/Hledger/Cli/Commands/Notes.hs
Stephen Morgan 9155d679fe fix!: Revert "fix!: utf-8: Use with-utf8 to ensure all files are read and written with utf8 encoding. (#1619)"
This reverts commit e233f001c5.

This would break at least some people's workflow. A lighter touch is
probably sufficient.
2022-06-01 09:35:18 +10:00

39 lines
877 B
Haskell

{-|
The @notes@ command lists all unique notes (description part after a |) seen in transactions, sorted alphabetically.
-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE CPP #-}
module Hledger.Cli.Commands.Notes (
notesmode
,notes
) where
import Data.List.Extra (nubSort)
import qualified Data.Text.IO as T
import Hledger
import Hledger.Cli.CliOptions
-- | Command line options for this command.
notesmode = hledgerCommandMode
$(embedFileRelative "Hledger/Cli/Commands/Notes.txt")
[]
[generalflagsgroup1]
hiddenflags
([], Just $ argsFlag "[QUERY]")
-- | The notes command.
notes :: CliOpts -> Journal -> IO ()
notes CliOpts{reportspec_=rspec} j = do
let ts = entriesReport rspec j
notes = nubSort $ map transactionNote ts
mapM_ T.putStrLn notes