mirror of
https://github.com/simonmichael/hledger.git
synced 2024-09-20 02:37:12 +03:00
the --format option shall be known as "line format"
This commit is contained in:
parent
7f6cf1f849
commit
301f506486
@ -284,7 +284,7 @@ balance :: CliOpts -> Journal -> IO ()
|
|||||||
balance CliOpts{reportopts_=ropts} j = do
|
balance CliOpts{reportopts_=ropts} j = do
|
||||||
d <- getCurrentDay
|
d <- getCurrentDay
|
||||||
let output =
|
let output =
|
||||||
case formatFromOpts ropts of
|
case lineFormatFromOpts ropts of
|
||||||
Left err -> [err]
|
Left err -> [err]
|
||||||
Right _ ->
|
Right _ ->
|
||||||
case (intervalFromOpts ropts, balancetype_ ropts) of
|
case (intervalFromOpts ropts, balancetype_ ropts) of
|
||||||
@ -298,7 +298,7 @@ balance CliOpts{reportopts_=ropts} j = do
|
|||||||
balanceReportAsText :: ReportOpts -> BalanceReport -> [String]
|
balanceReportAsText :: ReportOpts -> BalanceReport -> [String]
|
||||||
balanceReportAsText opts ((items, total)) = concat lines ++ t
|
balanceReportAsText opts ((items, total)) = concat lines ++ t
|
||||||
where
|
where
|
||||||
lines = case formatFromOpts opts of
|
lines = case lineFormatFromOpts opts of
|
||||||
Right f -> map (balanceReportItemAsText opts f) items
|
Right f -> map (balanceReportItemAsText opts f) items
|
||||||
Left err -> [[err]]
|
Left err -> [[err]]
|
||||||
t = if no_total_ opts
|
t = if no_total_ opts
|
||||||
|
@ -38,7 +38,7 @@ balancesheetmode = (defCommandMode $ ["balancesheet"]++aliases) {
|
|||||||
-- | Print a simple balance sheet.
|
-- | Print a simple balance sheet.
|
||||||
balancesheet :: CliOpts -> Journal -> IO ()
|
balancesheet :: CliOpts -> Journal -> IO ()
|
||||||
balancesheet CliOpts{reportopts_=ropts} j = do
|
balancesheet CliOpts{reportopts_=ropts} j = do
|
||||||
-- let lines = case formatFromOpts ropts of Left err, Right ...
|
-- let lines = case lineFormatFromOpts ropts of Left err, Right ...
|
||||||
d <- getCurrentDay
|
d <- getCurrentDay
|
||||||
let q = queryFromOpts d (withoutBeginDate ropts)
|
let q = queryFromOpts d (withoutBeginDate ropts)
|
||||||
assetreport@(_,assets) = balanceReport ropts (And [q, journalAssetAccountQuery j]) j
|
assetreport@(_,assets) = balanceReport ropts (And [q, journalAssetAccountQuery j]) j
|
||||||
|
@ -40,7 +40,7 @@ cashflowmode = (defCommandMode ["cashflow","cf"]) {
|
|||||||
-- | Print a simple cashflow statement.
|
-- | Print a simple cashflow statement.
|
||||||
cashflow :: CliOpts -> Journal -> IO ()
|
cashflow :: CliOpts -> Journal -> IO ()
|
||||||
cashflow CliOpts{reportopts_=ropts} j = do
|
cashflow CliOpts{reportopts_=ropts} j = do
|
||||||
-- let lines = case formatFromOpts ropts of Left err, Right ...
|
-- let lines = case lineFormatFromOpts ropts of Left err, Right ...
|
||||||
d <- getCurrentDay
|
d <- getCurrentDay
|
||||||
let q = queryFromOpts d ropts
|
let q = queryFromOpts d ropts
|
||||||
cashreport@(_,total) = balanceReport ropts (And [q, journalCashAccountQuery j]) j
|
cashreport@(_,total) = balanceReport ropts (And [q, journalCashAccountQuery j]) j
|
||||||
|
@ -44,7 +44,7 @@ module Hledger.Cli.Options (
|
|||||||
defaultWidthWithFlag,
|
defaultWidthWithFlag,
|
||||||
widthFromOpts,
|
widthFromOpts,
|
||||||
-- | For balance:
|
-- | For balance:
|
||||||
formatFromOpts,
|
lineFormatFromOpts,
|
||||||
|
|
||||||
-- * Other utils
|
-- * Other utils
|
||||||
hledgerAddons,
|
hledgerAddons,
|
||||||
@ -284,7 +284,7 @@ rawOptsToCliOpts rawopts = do
|
|||||||
-- | Do final validation of processed opts, raising an error if there is trouble.
|
-- | Do final validation of processed opts, raising an error if there is trouble.
|
||||||
checkCliOpts :: CliOpts -> IO CliOpts -- or pure..
|
checkCliOpts :: CliOpts -> IO CliOpts -- or pure..
|
||||||
checkCliOpts opts@CliOpts{reportopts_=ropts} = do
|
checkCliOpts opts@CliOpts{reportopts_=ropts} = do
|
||||||
case formatFromOpts ropts of
|
case lineFormatFromOpts ropts of
|
||||||
Left err -> optserror $ "could not parse format option: "++err
|
Left err -> optserror $ "could not parse format option: "++err
|
||||||
Right _ -> return ()
|
Right _ -> return ()
|
||||||
case widthFromOpts opts of
|
case widthFromOpts opts of
|
||||||
@ -351,12 +351,12 @@ rulesFilePathFromOpts opts = do
|
|||||||
|
|
||||||
-- | Parse the format option if provided, possibly returning an error,
|
-- | Parse the format option if provided, possibly returning an error,
|
||||||
-- otherwise get the default value.
|
-- otherwise get the default value.
|
||||||
formatFromOpts :: ReportOpts -> Either String [OutputFormat]
|
lineFormatFromOpts :: ReportOpts -> Either String [OutputFormat]
|
||||||
formatFromOpts = maybe (Right defaultBalanceFormat) parseStringFormat . format_
|
lineFormatFromOpts = maybe (Right defaultBalanceLineFormat) parseStringFormat . format_
|
||||||
|
|
||||||
-- | Default line format for balance report: "%20(total) %2(depth_spacer)%-(account)"
|
-- | Default line format for balance report: "%20(total) %2(depth_spacer)%-(account)"
|
||||||
defaultBalanceFormat :: [OutputFormat]
|
defaultBalanceLineFormat :: [OutputFormat]
|
||||||
defaultBalanceFormat = [
|
defaultBalanceLineFormat = [
|
||||||
FormatField False (Just 20) Nothing TotalField
|
FormatField False (Just 20) Nothing TotalField
|
||||||
, FormatLiteral " "
|
, FormatLiteral " "
|
||||||
, FormatField True (Just 2) Nothing DepthSpacerField
|
, FormatField True (Just 2) Nothing DepthSpacerField
|
||||||
|
Loading…
Reference in New Issue
Block a user