diff --git a/hledger/Hledger/Cli/Commands.hs b/hledger/Hledger/Cli/Commands.hs index af2d827da..851067267 100644 --- a/hledger/Hledger/Cli/Commands.hs +++ b/hledger/Hledger/Cli/Commands.hs @@ -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" diff --git a/hledger/Hledger/Cli/Commands/Payees.hs b/hledger/Hledger/Cli/Commands/Payees.hs new file mode 100644 index 000000000..293d166e7 --- /dev/null +++ b/hledger/Hledger/Cli/Commands/Payees.hs @@ -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 diff --git a/hledger/Hledger/Cli/Commands/Payees.md b/hledger/Hledger/Cli/Commands/Payees.md new file mode 100644 index 000000000..275e6c0a8 --- /dev/null +++ b/hledger/Hledger/Cli/Commands/Payees.md @@ -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 +``` diff --git a/hledger/Hledger/Cli/Commands/Payees.txt b/hledger/Hledger/Cli/Commands/Payees.txt new file mode 100644 index 000000000..e22b818b3 --- /dev/null +++ b/hledger/Hledger/Cli/Commands/Payees.txt @@ -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 diff --git a/hledger/hledger.cabal b/hledger/hledger.cabal index 8829fc497..125761883 100644 --- a/hledger/hledger.cabal +++ b/hledger/hledger.cabal @@ -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 diff --git a/hledger/package.yaml b/hledger/package.yaml index d9ba46abf..c96bc120a 100644 --- a/hledger/package.yaml +++ b/hledger/package.yaml @@ -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