From 56226d72e68cbf96ba177a43b6e0af50d04881b8 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Sat, 24 Jul 2010 19:08:33 +0000 Subject: [PATCH] add -D/--daily flag --- Hledger/Cli/Options.hs | 5 ++++- Hledger/Cli/Tests.hs | 1 + MANUAL.markdown | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Hledger/Cli/Options.hs b/Hledger/Cli/Options.hs index 650b2585b..d427fd180 100644 --- a/Hledger/Cli/Options.hs +++ b/Hledger/Cli/Options.hs @@ -87,6 +87,7 @@ options = [ ,Option "" ["flat"] (NoArg Flat) "balance: show full account names, unindented" ,Option "" ["drop"] (ReqArg Drop "N") "balance: with --flat, elide first N account name components" ,Option "" ["no-total"] (NoArg NoTotal) "balance: hide the final total" + ,Option "D" ["daily"] (NoArg DailyOpt) "register, stats: report by day" ,Option "W" ["weekly"] (NoArg WeeklyOpt) "register, stats: report by week" ,Option "M" ["monthly"] (NoArg MonthlyOpt) "register, stats: report by month" ,Option "Q" ["quarterly"] (NoArg QuarterlyOpt) "register, stats: report by quarter" @@ -131,6 +132,7 @@ data Opt = Drop {value::String} | NoTotal | SubTotal | + DailyOpt | WeeklyOpt | MonthlyOpt | QuarterlyOpt | @@ -215,6 +217,7 @@ intervalFromOpts :: [Opt] -> Interval intervalFromOpts opts = case (periodopts, intervalopts) of ((p:_), _) -> fst $ parsePeriodExpr d p where d = parsedate "0001/01/01" -- unused + (_, (DailyOpt:_)) -> Daily (_, (WeeklyOpt:_)) -> Weekly (_, (MonthlyOpt:_)) -> Monthly (_, (QuarterlyOpt:_)) -> Quarterly @@ -222,7 +225,7 @@ intervalFromOpts opts = (_, _) -> NoInterval where periodopts = reverse $ optValuesForConstructor Period opts - intervalopts = reverse $ filter (`elem` [WeeklyOpt,MonthlyOpt,QuarterlyOpt,YearlyOpt]) opts + intervalopts = reverse $ filter (`elem` [DailyOpt,WeeklyOpt,MonthlyOpt,QuarterlyOpt,YearlyOpt]) opts -- | Get the value of the (last) depth option, if any. depthFromOpts :: [Opt] -> Maybe Int diff --git a/Hledger/Cli/Tests.hs b/Hledger/Cli/Tests.hs index c40b18073..45a950744 100644 --- a/Hledger/Cli/Tests.hs +++ b/Hledger/Cli/Tests.hs @@ -323,6 +323,7 @@ tests = TestList [ ,"intervalFromOpts" ~: do let gives = is . intervalFromOpts [] `gives` NoInterval + [DailyOpt] `gives` Daily [WeeklyOpt] `gives` Weekly [MonthlyOpt] `gives` Monthly [QuarterlyOpt] `gives` Quarterly diff --git a/MANUAL.markdown b/MANUAL.markdown index 2ecb9152d..088e58ad3 100644 --- a/MANUAL.markdown +++ b/MANUAL.markdown @@ -233,6 +233,7 @@ Here is the command-line help: --flat balance: show full account names, unindented --drop=N balance: with --flat, elide first N account name components --no-total balance: hide the final total + -D --daily register, stats: report by day -W --weekly register, stats: report by week -M --monthly register, stats: report by month -Q --quarterly register, stats: report by quarter