payees: Add a module for handling payees command

This commit is contained in:
Caleb Maclennan 2019-07-10 11:33:41 +03:00 committed by Simon Michael
parent a45b42bed5
commit e6b709cb01
6 changed files with 85 additions and 0 deletions

View File

@ -32,6 +32,7 @@ module Hledger.Cli.Commands (
,module Hledger.Cli.Commands.Help
,module Hledger.Cli.Commands.Import
,module Hledger.Cli.Commands.Incomestatement
,module Hledger.Cli.Commands.Payees
,module Hledger.Cli.Commands.Prices
,module Hledger.Cli.Commands.Print
,module Hledger.Cli.Commands.Printunique
@ -75,6 +76,7 @@ import Hledger.Cli.Commands.Files
import Hledger.Cli.Commands.Help
import Hledger.Cli.Commands.Import
import Hledger.Cli.Commands.Incomestatement
import Hledger.Cli.Commands.Payees
import Hledger.Cli.Commands.Prices
import Hledger.Cli.Commands.Print
import Hledger.Cli.Commands.Printunique
@ -107,6 +109,7 @@ builtinCommands = [
,(filesmode , files)
,(diffmode , diff)
,(incomestatementmode , incomestatement)
,(payeesmode , payees)
,(pricesmode , prices)
,(printmode , print')
,(printuniquemode , printunique)
@ -173,6 +176,7 @@ commandsList = unlines [
," balance (b, bal) show balance changes/end balances/budgets in accounts"
," commodities show commodity/currency symbols"
," files show input file paths"
," payees show payees"
," prices show market price records"
," print (p, txns) show transactions (journal entries)"
," print-unique show only transactions with unique descriptions"

View File

@ -0,0 +1,47 @@
{-|
The @payees@ command lists payees:
- with the notes option the note field is included along with payees
-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE CPP #-}
module Hledger.Cli.Commands.Payees (
payeesmode
,payees
) where
#if !(MIN_VERSION_base(4,11,0))
import Data.Monoid
#endif
import Data.List
import qualified Data.Text as T
import qualified Data.Text.IO as T
import System.Console.CmdArgs.Explicit as C
import Hledger
import Hledger.Cli.CliOptions
-- | Command line options for this command.
payeesmode = hledgerCommandMode
$(embedFileRelative "Hledger/Cli/Commands/Payees.txt")
[flagNone ["notes"] (setboolopt "notes") "include note field with payees"
]
[generalflagsgroup1]
hiddenflags
([], Just $ argsFlag "[QUERY]")
-- | The payees command.
payees :: CliOpts -> Journal -> IO ()
payees CliOpts{rawopts_=rawopts, reportopts_=ropts} j = do
let notes = notes_ ropts
payees = []
mapM_ (T.putStrLn . render) payees

View File

@ -0,0 +1,15 @@
payees
Show payee names.
_FLAGS_
This command lists all payee names that appear in transactions. With the optional notes directive (`--notes`) it will include the note field along with the base payee name.
Examples:
```shell
$ hledger payees
Store Name
Gas Station
Person A
```

View File

@ -0,0 +1,15 @@
payees
Show payee names.
_FLAGS_
This command lists all payee names that appear in transactions. With the
optional notes directive (--notes) it will include the note field along
with the base payee name.
Examples:
$ hledger payees
Store Name
Gas Station
Person A

View File

@ -77,6 +77,7 @@ extra-source-files:
Hledger/Cli/Commands/Help.txt
Hledger/Cli/Commands/Import.txt
Hledger/Cli/Commands/Incomestatement.txt
Hledger/Cli/Commands/Payees.txt
Hledger/Cli/Commands/Prices.txt
Hledger/Cli/Commands/Print.txt
Hledger/Cli/Commands/Printunique.txt
@ -127,6 +128,7 @@ library
Hledger.Cli.Commands.Files
Hledger.Cli.Commands.Import
Hledger.Cli.Commands.Incomestatement
Hledger.Cli.Commands.Payees
Hledger.Cli.Commands.Prices
Hledger.Cli.Commands.Print
Hledger.Cli.Commands.Printunique

View File

@ -70,6 +70,7 @@ extra-source-files:
- Hledger/Cli/Commands/Help.txt
- Hledger/Cli/Commands/Import.txt
- Hledger/Cli/Commands/Incomestatement.txt
- Hledger/Cli/Commands/Payees.txt
- Hledger/Cli/Commands/Prices.txt
- Hledger/Cli/Commands/Print.txt
- Hledger/Cli/Commands/Printunique.txt
@ -172,6 +173,7 @@ library:
- Hledger.Cli.Commands.Files
- Hledger.Cli.Commands.Import
- Hledger.Cli.Commands.Incomestatement
- Hledger.Cli.Commands.Payees
- Hledger.Cli.Commands.Prices
- Hledger.Cli.Commands.Print
- Hledger.Cli.Commands.Printunique