Safe Haskell | None |
---|---|
Language | Haskell2010 |
Parse format strings provided by --format, with awareness of hledger's report item fields. The formats are used by report-specific renderers like renderBalanceReportItem.
Synopsis
- parseStringFormat :: String -> Either String StringFormat
- defaultStringFormatStyle :: Maybe Int -> [StringFormatComponent] -> StringFormat
- data StringFormat
- data StringFormatComponent
- data ReportItemField
- overlineWidth :: StringFormat -> Maybe Int
- defaultBalanceLineFormat :: StringFormat
- tests_StringFormat :: TestTree
Documentation
parseStringFormat :: String -> Either String StringFormat Source #
Parse a string format specification, or return a parse error.
data StringFormat Source #
A format specification/template to use when rendering a report line item as text.
A format is an optional width, along with a sequence of components; each is either a literal string, or a hledger report item field with specified width and justification whose value will be interpolated at render time. The optional width determines the length of the overline to draw above the totals row; if it is Nothing, then the maximum width of all lines is used.
A component's value may be a multi-line string (or a multi-commodity amount), in which case the final string will be either single-line or a top or bottom-aligned multi-line string depending on the StringFormat variant used.
Currently this is only used in the balance command's single-column mode, which provides a limited StringFormat renderer.
OneLine (Maybe Int) [StringFormatComponent] | multi-line values will be rendered on one line, comma-separated |
TopAligned (Maybe Int) [StringFormatComponent] | values will be top-aligned (and bottom-padded to the same height) |
BottomAligned (Maybe Int) [StringFormatComponent] | values will be bottom-aligned (and top-padded) |
Instances
Eq StringFormat Source # | |
Defined in Hledger.Data.StringFormat (==) :: StringFormat -> StringFormat -> Bool # (/=) :: StringFormat -> StringFormat -> Bool # | |
Show StringFormat Source # | |
Defined in Hledger.Data.StringFormat showsPrec :: Int -> StringFormat -> ShowS # show :: StringFormat -> String # showList :: [StringFormat] -> ShowS # | |
Default StringFormat Source # | |
Defined in Hledger.Data.StringFormat def :: StringFormat # |
data StringFormatComponent Source #
FormatLiteral String | Literal text to be rendered as-is |
FormatField Bool (Maybe Int) (Maybe Int) ReportItemField | A data field to be formatted and interpolated. Parameters:
|
Instances
Eq StringFormatComponent Source # | |
Defined in Hledger.Data.StringFormat (==) :: StringFormatComponent -> StringFormatComponent -> Bool # (/=) :: StringFormatComponent -> StringFormatComponent -> Bool # | |
Show StringFormatComponent Source # | |
Defined in Hledger.Data.StringFormat showsPrec :: Int -> StringFormatComponent -> ShowS # show :: StringFormatComponent -> String # showList :: [StringFormatComponent] -> ShowS # |
data ReportItemField Source #
An id identifying which report item field to interpolate. These are drawn from several hledger report types, so are not all applicable for a given report.
AccountField | A posting or balance report item's account name |
DefaultDateField | A posting or register or entry report item's date |
DescriptionField | A posting or register or entry report item's description |
TotalField | A balance or posting report item's balance or running total. Always rendered right-justified. |
DepthSpacerField | A balance report item's indent level (which may be different from the account name depth). Rendered as this number of spaces, multiplied by the minimum width spec if any. |
FieldNo Int | A report item's nth field. May be unimplemented. |
Instances
Eq ReportItemField Source # | |
Defined in Hledger.Data.StringFormat (==) :: ReportItemField -> ReportItemField -> Bool # (/=) :: ReportItemField -> ReportItemField -> Bool # | |
Show ReportItemField Source # | |
Defined in Hledger.Data.StringFormat showsPrec :: Int -> ReportItemField -> ShowS # show :: ReportItemField -> String # showList :: [ReportItemField] -> ShowS # |
overlineWidth :: StringFormat -> Maybe Int Source #
defaultBalanceLineFormat :: StringFormat Source #
Default line format for balance report: "%20(total) %2(depth_spacer)%-(account)"