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