Safe Haskell | None |
---|
Liberty - Penny command line parsing utilities
Both Cabin and Zinc share various functions that aid in parsing command lines. For instance both the Postings report and the Zinc postings filter use common command-line options. However, Zinc already depends on Cabin. To avoid a cyclic dependency whereby Cabin would also depend on Zinc, functions formerly in Zinc that Cabin will also find useful are relocated here, to Liberty.
- type MatcherFactory = CaseSensitive -> Text -> Either Text Matcher
- newtype FilteredNum = FilteredNum {}
- newtype SortedNum = SortedNum {}
- data LibertyMeta
- xactionsToFiltered :: LPdct -> [PostFilterFn] -> (Posting -> Posting -> Ordering) -> [Transaction] -> ((Amount Qty -> Text) -> [Chunk], [(LibertyMeta, Posting)])
- newtype ListLength = ListLength {
- unListLength :: Int
- newtype ItemIndex = ItemIndex {
- unItemIndex :: Int
- type PostFilterFn = ListLength -> ItemIndex -> Bool
- parseComparer :: String -> (Ordering -> Pdct a) -> Either InputError (Pdct a)
- processPostFilters :: [PostFilterFn] -> [a] -> [a]
- parsePredicate :: ExprDesc -> [Token a] -> Either Error (Pdct a)
- parseInt :: String -> Either Error Int
- parseIntMA :: String -> Either InputError Int
- parseInfix :: OptSpec ExprDesc
- parseRPN :: OptSpec ExprDesc
- exprDesc :: [OptSpec ExprDesc]
- showExpression :: OptSpec ()
- verboseFilter :: OptSpec ()
- type Operand = Pdct Posting
- operandSpecs :: DateTime -> [OptSpec (CaseSensitive -> MatcherFactory -> Either Error Operand)]
- postFilterSpecs :: (OptSpec PostFilterFn, OptSpec PostFilterFn)
- matcherSelectSpecs :: [OptSpec MatcherFactory]
- caseSelectSpecs :: [OptSpec CaseSensitive]
- operatorSpecs :: [OptSpec (Token a)]
- version :: Version -> String -> String
- output :: OptSpec (Text -> IO ())
- processOutput :: [Text -> IO ()] -> Text -> IO ()
- type Error = Text
Documentation
type MatcherFactory = CaseSensitive -> Text -> Either Text MatcherSource
newtype FilteredNum Source
A serial indicating how a post relates to all other postings that made it through the filtering phase.
A serial indicating how a posting relates to all other postings that have been sorted.
:: LPdct | The predicate to filter the transactions |
-> [PostFilterFn] | Post filter specs |
-> (Posting -> Posting -> Ordering) | The sorter |
-> [Transaction] | The transactions to work on (probably parsed in from Copper) |
-> ((Amount Qty -> Text) -> [Chunk], [(LibertyMeta, Posting)]) | Sorted, filtered postings |
Takes a list of transactions, splits them into PostingChild instances, filters them, post-filters them, sorts them, and places them in Box instances with Filtered serials. Also returns Chunks containing a description of the evalutation process.
newtype ListLength Source
type PostFilterFn = ListLength -> ItemIndex -> BoolSource
Specifies options for the post-filter stage.
parseComparer :: String -> (Ordering -> Pdct a) -> Either InputError (Pdct a)Source
Parses comparers given on command line to a function. Fails if the string given is invalid.
processPostFilters :: [PostFilterFn] -> [a] -> [a]Source
parsePredicate :: ExprDesc -> [Token a] -> Either Error (Pdct a)Source
Parses a list of tokens to obtain a predicate. Deals with an empty list of tokens by returning a predicate that is always True. Fails if the list of tokens is not empty and the parse fails.
parseInt :: String -> Either Error IntSource
Parses exactly one integer; fails if it cannot read exactly one.
showExpression :: OptSpec ()Source
verboseFilter :: OptSpec ()Source
Parsers
operandSpecs :: DateTime -> [OptSpec (CaseSensitive -> MatcherFactory -> Either Error Operand)]Source
All operand OptSpec.
operatorSpecs :: [OptSpec (Token a)]Source
Version
Prints the binary's version and the version of the library, and exits successfully.
Output
processOutput :: [Text -> IO ()] -> Text -> IO ()Source
Given a list of output options, returns a single IO action to write to all given files. If the list was empty, returns an IO action that writes to standard output.