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 -> Exceptional Text Matcher
- newtype FilteredNum = FilteredNum {}
- newtype SortedNum = SortedNum {}
- data LibertyMeta
- xactionsToFiltered :: LPdct -> [PostFilterFn] -> (Posting -> Posting -> Ordering) -> [Transaction] -> ([Chunk], [(LibertyMeta, Posting)])
- newtype ListLength = ListLength {
- unListLength :: Int
- newtype ItemIndex = ItemIndex {
- unItemIndex :: Int
- type PostFilterFn = ListLength -> ItemIndex -> Bool
- parseComparer :: String -> (Ordering -> Pdct a) -> Exceptional Error (Pdct a)
- processPostFilters :: [PostFilterFn] -> [a] -> [a]
- parsePredicate :: ExprDesc -> [Token a] -> Exceptional Error (Pdct a)
- parseInt :: String -> Exceptional Error Int
- parseInfix :: OptSpec ExprDesc
- parseRPN :: OptSpec ExprDesc
- exprDesc :: [OptSpec ExprDesc]
- showExpression :: OptSpec ()
- verboseFilter :: OptSpec ()
- type Operand = Pdct Posting
- operandSpecs :: DateTime -> [OptSpec (CaseSensitive -> MatcherFactory -> Exceptional Error Operand)]
- postFilterSpecs :: (OptSpec (Exceptional Error PostFilterFn), OptSpec (Exceptional Error PostFilterFn))
- matcherSelectSpecs :: [OptSpec MatcherFactory]
- caseSelectSpecs :: [OptSpec CaseSensitive]
- operatorSpecs :: [OptSpec (Token a)]
- version :: Version -> OptSpec (IO a)
- output :: OptSpec (Text -> IO ())
- processOutput :: [Text -> IO ()] -> Text -> IO ()
- type Error = Text
Documentation
type MatcherFactory = CaseSensitive -> Text -> Exceptional 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) |
-> ([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) -> Exceptional Error (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] -> Exceptional 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 -> Exceptional 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 -> Exceptional Error Operand)]Source
All operand OptSpec.
postFilterSpecs :: (OptSpec (Exceptional Error PostFilterFn), OptSpec (Exceptional Error PostFilterFn))Source
operatorSpecs :: [OptSpec (Token a)]Source
Version
Parses the --version
option and returns an IO action that
prints it and exits successfully. You supply the version of the
executable, as there is no easy way to get that automatically.
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.