diff --git a/hledger/Hledger/Cli/Commands.hs b/hledger/Hledger/Cli/Commands.hs index b62edc768..333968ff2 100644 --- a/hledger/Hledger/Cli/Commands.hs +++ b/hledger/Hledger/Cli/Commands.hs @@ -25,8 +25,6 @@ module Hledger.Cli.Commands ( ,module Hledger.Cli.Commands.Balancesheet ,module Hledger.Cli.Commands.Balancesheetequity ,module Hledger.Cli.Commands.Cashflow - ,module Hledger.Cli.Commands.Checkdates - ,module Hledger.Cli.Commands.Checkdupes ,module Hledger.Cli.Commands.Close ,module Hledger.Cli.Commands.Codes ,module Hledger.Cli.Commands.Commodities @@ -73,8 +71,6 @@ import Hledger.Cli.Commands.Balancesheet import Hledger.Cli.Commands.Balancesheetequity import Hledger.Cli.Commands.Cashflow import Hledger.Cli.Commands.Check -import Hledger.Cli.Commands.Checkdates -import Hledger.Cli.Commands.Checkdupes import Hledger.Cli.Commands.Close import Hledger.Cli.Commands.Codes import Hledger.Cli.Commands.Commodities @@ -111,8 +107,6 @@ builtinCommands = [ ,(balancesheetmode , balancesheet) ,(cashflowmode , cashflow) ,(checkmode , check) - ,(checkdatesmode , checkdates) - ,(checkdupesmode , checkdupes) ,(closemode , close) ,(codesmode , codes) ,(commoditiesmode , commodities) diff --git a/hledger/Hledger/Cli/Commands/Check.hs b/hledger/Hledger/Cli/Commands/Check.hs index b79fefa6a..5983f2a91 100644 --- a/hledger/Hledger/Cli/Commands/Check.hs +++ b/hledger/Hledger/Cli/Commands/Check.hs @@ -11,8 +11,8 @@ module Hledger.Cli.Commands.Check ( import Hledger import Hledger.Cli.CliOptions -import Hledger.Cli.Commands.Checkdupes (checkdupes) -import Hledger.Cli.Commands.Checkdates (checkdates) +import Hledger.Cli.Commands.Check.Ordereddates (journalCheckOrdereddates) +import Hledger.Cli.Commands.Check.Uniqueleafnames (journalCheckUniqueleafnames) import System.Console.CmdArgs.Explicit import Data.Either (partitionEithers) import Data.Char (toUpper) @@ -82,11 +82,11 @@ runCheck copts@CliOpts{rawopts_} j (check,args) = Commodities -> case journalCheckCommoditiesDeclared j of Right () -> return () Left err -> hPutStrLn stderr ("Error: "++err) >> exitFailure - Ordereddates -> checkdates copts' j + Ordereddates -> journalCheckOrdereddates copts' j Payees -> case journalCheckPayeesDeclared j of Right () -> return () Left err -> hPutStrLn stderr ("Error: "++err) >> exitFailure - Uniqueleafnames -> checkdupes copts' j + Uniqueleafnames -> journalCheckUniqueleafnames j where -- Hack: append the provided args to the raw opts, -- in case the check can use them (like checkdates --unique). diff --git a/hledger/Hledger/Cli/Commands/Checkdates.hs b/hledger/Hledger/Cli/Commands/Check/Ordereddates.hs similarity index 75% rename from hledger/Hledger/Cli/Commands/Checkdates.hs rename to hledger/Hledger/Cli/Commands/Check/Ordereddates.hs index cf37bcc1c..5b2f299eb 100755 --- a/hledger/Hledger/Cli/Commands/Checkdates.hs +++ b/hledger/Hledger/Cli/Commands/Check/Ordereddates.hs @@ -1,31 +1,18 @@ -{-# LANGUAGE NoOverloadedStrings #-} -- prevent trouble if turned on in ghci -{-# LANGUAGE TemplateHaskell #-} - -module Hledger.Cli.Commands.Checkdates ( - checkdatesmode - ,checkdates -) where +module Hledger.Cli.Commands.Check.Ordereddates ( + journalCheckOrdereddates +) +where import Hledger import Hledger.Cli.CliOptions -import System.Console.CmdArgs.Explicit import System.Exit import Text.Printf -checkdatesmode :: Mode RawOpts -checkdatesmode = hledgerCommandMode - $(embedFileRelative "Hledger/Cli/Commands/Checkdates.txt") - [flagNone ["unique"] (setboolopt "unique") "require that dates are unique"] - [generalflagsgroup1] - hiddenflags - ([], Just $ argsFlag "[QUERY]") - -checkdates :: CliOpts -> Journal -> IO () -checkdates CliOpts{rawopts_=rawopts,reportspec_=rspec} j = do +journalCheckOrdereddates :: CliOpts -> Journal -> IO () +journalCheckOrdereddates CliOpts{rawopts_=rawopts,reportspec_=rspec} j = do let ropts = (rsOpts rspec){accountlistmode_=ALFlat} let ts = filter (rsQuery rspec `matchesTransaction`) $ jtxns $ journalSelectingAmountFromOpts ropts j - -- pprint rawopts let unique = boolopt "--unique" rawopts -- TEMP: it's this for hledger check dates || boolopt "unique" rawopts -- and this for hledger check-dates (for some reason) let date = transactionDateFn ropts diff --git a/hledger/Hledger/Cli/Commands/Checkdupes.hs b/hledger/Hledger/Cli/Commands/Check/Uniqueleafnames.hs similarity index 73% rename from hledger/Hledger/Cli/Commands/Checkdupes.hs rename to hledger/Hledger/Cli/Commands/Check/Uniqueleafnames.hs index d6c93add0..7ba9e99dc 100755 --- a/hledger/Hledger/Cli/Commands/Checkdupes.hs +++ b/hledger/Hledger/Cli/Commands/Check/Uniqueleafnames.hs @@ -1,8 +1,5 @@ -{-# LANGUAGE TemplateHaskell #-} - -module Hledger.Cli.Commands.Checkdupes ( - checkdupesmode - ,checkdupes +module Hledger.Cli.Commands.Check.Uniqueleafnames ( + journalCheckUniqueleafnames ) where @@ -11,21 +8,11 @@ import Data.List import Data.List.Extra (nubSort) import qualified Data.Text as T import Hledger -import Hledger.Cli.CliOptions -import System.Console.CmdArgs.Explicit import Text.Printf import System.Exit (exitFailure) import Control.Monad (when) -checkdupesmode :: Mode RawOpts -checkdupesmode = hledgerCommandMode - $(embedFileRelative "Hledger/Cli/Commands/Checkdupes.txt") - [] - [generalflagsgroup1] - hiddenflags - ([], Nothing) - -checkdupes _opts j = do +journalCheckUniqueleafnames j = do let dupes = checkdupes' $ accountsNames j when (not $ null dupes) $ do -- XXX make output more like Checkdates.hs, Check.hs etc. diff --git a/hledger/Hledger/Cli/Commands/Checkdates.md b/hledger/Hledger/Cli/Commands/Checkdates.md deleted file mode 100644 index 9eff491ad..000000000 --- a/hledger/Hledger/Cli/Commands/Checkdates.md +++ /dev/null @@ -1,8 +0,0 @@ -check-dates\ -Check that transactions are sorted by increasing date. -With --date2, checks secondary dates instead. -With --strict, dates must also be unique. -With a query, only matched transactions' dates are checked. -Reads the default journal file, or another specified with -f. - -_FLAGS diff --git a/hledger/Hledger/Cli/Commands/Checkdates.txt b/hledger/Hledger/Cli/Commands/Checkdates.txt deleted file mode 100644 index cb74a343d..000000000 --- a/hledger/Hledger/Cli/Commands/Checkdates.txt +++ /dev/null @@ -1,7 +0,0 @@ -check-dates -Check that transactions are sorted by increasing date. With --date2, -checks secondary dates instead. With --strict, dates must also be -unique. With a query, only matched transactions' dates are checked. -Reads the default journal file, or another specified with -f. - -_FLAGS diff --git a/hledger/Hledger/Cli/Commands/Checkdupes.md b/hledger/Hledger/Cli/Commands/Checkdupes.md deleted file mode 100644 index c785a9ccf..000000000 --- a/hledger/Hledger/Cli/Commands/Checkdupes.md +++ /dev/null @@ -1,8 +0,0 @@ -check-dupes\ -Reports account names having the same leaf but different prefixes. -In other words, two or more leaves that are categorized differently. -Reads the default journal file, or another specified as an argument. - -_FLAGS - -An example: diff --git a/hledger/Hledger/Cli/Commands/Checkdupes.txt b/hledger/Hledger/Cli/Commands/Checkdupes.txt deleted file mode 100644 index 3ed4af0a2..000000000 --- a/hledger/Hledger/Cli/Commands/Checkdupes.txt +++ /dev/null @@ -1,8 +0,0 @@ -check-dupes -Reports account names having the same leaf but different prefixes. In -other words, two or more leaves that are categorized differently. Reads -the default journal file, or another specified as an argument. - -_FLAGS - -An example: http://stefanorodighiero.net/software/hledger-dupes.html diff --git a/hledger/package.yaml b/hledger/package.yaml index 90c3bc4cb..d267f5e27 100644 --- a/hledger/package.yaml +++ b/hledger/package.yaml @@ -49,8 +49,6 @@ extra-source-files: - Hledger/Cli/Commands/Balancesheetequity.txt - Hledger/Cli/Commands/Cashflow.txt - Hledger/Cli/Commands/Check.txt -- Hledger/Cli/Commands/Checkdates.txt -- Hledger/Cli/Commands/Checkdupes.txt - Hledger/Cli/Commands/Close.txt - Hledger/Cli/Commands/Codes.txt - Hledger/Cli/Commands/Commodities.txt @@ -157,8 +155,8 @@ library: - Hledger.Cli.Commands.Balancesheetequity - Hledger.Cli.Commands.Cashflow - Hledger.Cli.Commands.Check - - Hledger.Cli.Commands.Checkdates - - Hledger.Cli.Commands.Checkdupes + - Hledger.Cli.Commands.Check.Ordereddates + - Hledger.Cli.Commands.Check.Uniqueleafnames - Hledger.Cli.Commands.Close - Hledger.Cli.Commands.Codes - Hledger.Cli.Commands.Commodities diff --git a/hledger/test/check-ordereddates.test b/hledger/test/check-ordereddates.test index fc640af2c..be703c865 100644 --- a/hledger/test/check-ordereddates.test +++ b/hledger/test/check-ordereddates.test @@ -14,4 +14,8 @@ $ hledger -f- check ordereddates $ hledger -f- check ordereddates > /transaction date is out of order/ >=1 -# XXX make it >2 +# XXX +# make it >2 +# With --date2, it checks secondary dates instead. +# With --strict, dates must also be unique. +# With a query, only matched transactions' dates are checked. diff --git a/hledger/test/check-uniqueleafnames.test b/hledger/test/check-uniqueleafnames.test index b1ccef8ce..3b4bd84c2 100644 --- a/hledger/test/check-uniqueleafnames.test +++ b/hledger/test/check-uniqueleafnames.test @@ -13,4 +13,9 @@ $ hledger -f- check uniqueleafnames $ hledger -f- check uniqueleafnames > /a as a, b:a/ >=1 -# XXX make it >2; improve message +# XXX +# make it >2; improve message +# Reports account names having the same leaf but different prefixes. +# In other words, two or more leaves that are categorized differently. +# Reads the default journal file, or another specified as an argument. +# An example: