| 1 |
{-| |
| 2 |
|
| 3 |
The @notes@ command lists all unique notes (description part after a |) seen in transactions, sorted alphabetically. |
| 4 |
|
| 5 |
-} |
| 6 |
|
| 7 |
{-# LANGUAGE MultiWayIf #-} |
| 8 |
{-# LANGUAGE OverloadedStrings #-} |
| 9 |
{-# LANGUAGE ScopedTypeVariables #-} |
| 10 |
{-# LANGUAGE TemplateHaskell #-} |
| 11 |
{-# LANGUAGE CPP #-} |
| 12 |
|
| 13 |
module Hledger.Cli.Commands.Notes ( |
| 14 |
notesmode |
| 15 |
,notes |
| 16 |
) where |
| 17 |
|
| 18 |
import Data.List.Extra (nubSort) |
| 19 |
import Data.Text.IO qualified as T |
| 20 |
|
| 21 |
import Hledger |
| 22 |
import Hledger.Cli.CliOptions |
| 23 |
|
| 24 |
|
| 25 |
-- | Command line options for this command. |
| 26 |
notesmode = hledgerCommandMode |
| 27 |
$(embedFileRelative "Hledger/Cli/Commands/Notes.txt") |
| 28 |
[] |
| 29 |
cligeneralflagsgroups1 |
| 30 |
hiddenflags |
| 31 |
([], Just $ argsFlag "[QUERY]") |
| 32 |
|
| 33 |
-- | The notes command. |
| 34 |
notes :: CliOpts -> Journal -> IO () |
| 35 |
notes CliOpts{reportspec_=rspec} j = do |
| 36 |
let ts = entriesReport rspec j |
| 37 |
notes' = nubSort $ map transactionNote ts |
| 38 |
mapM_ T.putStrLn notes' |