penny-bin 0.6.0.0 → 0.6.2.0
raw patch · 4 files changed
+299/−299 lines, 4 files
Files
- man/penny-custom.7 +2/−2
- penny-bin.cabal +2/−2
- penny-main.hs +295/−0
- penny.hs +0/−295
man/penny-custom.7 view
@@ -43,14 +43,14 @@ even if you know little or no Haskell. Then, from the directory that has your-.I penny.hs+.I penny-main.hs file, run .I cabal install and you should be all set, if you have already set up the .B cabal program to install programs to a location that is in your path. Alternatively, run-.I ghc --make penny.hs+.I ghc --make -o penny penny-main.hs and then you will have a .B penny binary in the current directory and you can do what you want with it.
penny-bin.cabal view
@@ -1,5 +1,5 @@ Name: penny-bin-Version: 0.6.0.0+Version: 0.6.2.0 Cabal-version: >=1.8 Build-Type: Simple License: BSD3@@ -184,7 +184,7 @@ base ==4.*, penny-lib ==0.6.0.0 - Main-is: penny.hs+ Main-is: penny-main.hs GHC-Options: -Wall if flag(debug) GHC-Options: -rtsopts -auto-all -caf-all
+ penny-main.hs view
@@ -0,0 +1,295 @@+module Main where++import Penny++-- | This type contains settings for all the reports, as well as+-- default settings for the global options. Some of these can be+-- overridden on the command line.+defaults :: Runtime -> Defaults+defaults rt = Defaults+ { caseSensitive = False+ -- ^ Whether the matcher is case sensitive by default++ , matcher = Within+ -- ^ Which matcher to use. Your choices:+ -- Within+ -- Exact+ -- TDFA (regular expressions, POSIX semantics)+ -- PCRE (regular expressions, PCRE semantics)++ , colorToFile = False+ -- ^ Use colors when standard output is not a terminal?++ , defaultScheme = Just schemeDark+ -- ^ Default color scheme. If Nothing, there is no default color+ -- scheme. If there is no default color scheme and the user does+ -- not pick one on the command line, no colors will be used.++ , additionalSchemes = [schemeDark, schemeLight, schemePlain]+ -- ^ Additional color schemes the user can pick from on the+ -- command line.++ , sorter = [(Date, Ascending)]+ -- ^ Postings are sorted in this order by default. For example, if+ -- the first pair is (Date, Ascending), then postings are first+ -- sorted by date in ascending order. If the second pair is+ -- (Payee, Ascending), then postings with the same date are then+ -- sorted by payee.+ --+ -- If this list is empty, then by default postings are left in the+ -- same order as they appear in the ledger files.++ , balanceFormat = const defaultQtyFormat+ -- ^ How to format balances in the balance report. Change this+ -- function if, for example, you want to allow for digit+ -- grouping. The default function does not perform digit grouping.++ , balanceShowZeroBalances = False+ -- ^ Show zero balances in the balance report? If True, show them;+ -- if False, hide them.++ , balanceOrder = Ascending+ -- ^ Whether to sort the accounts in ascending or descending order+ -- by account name in the balance report. Your choices: Ascending+ -- or Descending.++ , convertShowZeroBalances = False+ -- ^ Show zero balances in the convert report? If True, show them;+ -- if False, hide them.++ , convertTarget = AutoTarget+ -- ^ The commodity to which to convert the commodities in the+ -- convert report. Your choices:+ --+ -- AutoTarget - selects a target commodity automatically, based on+ -- which commodity is the most common target commodity in the+ -- prices in your ledger files. If there is a tie for most common+ -- target commodity, the target that appears later in your ledger+ -- files is used.+ --+ -- ManualTarget CMDTY_NAME - always use the given commodity.++ , convertOrder = Ascending+ -- ^ Sort the convert report in ascending or descending order.++ , convertSortBy = SortByName+ -- ^ Sort by account or by quantity in the convert report. Your+ -- choices:+ --+ -- SortByQty+ -- SortByName++ , convertFormat = const defaultQtyFormat+ -- ^ How to format balances in the convert report. For instance,+ -- this function might perform digit grouping. The default+ -- function does not perform any digit grouping.++ , postingsFields = fields+ -- ^ Fields to show by default in the postings report.++ , postingsWidth = widthFromRuntime rt+ -- ^ The postings report is roughly this wide by default. Use+ -- @widthFromRuntime rt@ if you want to use the current width of+ -- your terminal.++ , postingsShowZeroBalances = False+ -- ^ Show zero balances in the postings report? If True, show+ -- them; if False, hide them.++ , postingsDateFormat = yearMonthDay+ -- ^ How to format dates in the postings report.++ , postingsQtyFormat = qtyAsIs+ -- ^ How to format quantities in the balance report. This function+ -- is used when showing the quantity for the posting itself, and+ -- not the quantity for the totals columns (for that, see+ -- postingsBalanceFormat.) For example this function might perform+ -- digit grouping.++ , postingsBalanceFormat = balanceAsIs+ -- ^ How to format balance totals in the postings report.++ , postingsSubAccountLength = 2+ -- ^ Account names in the postings report are shortened if+ -- necessary in order to help the report fit within the allotted+ -- width (see postingsWidth). Account names are only shortened as+ -- much as is necessary for them to fit; however, each sub-account+ -- name will not be shortened any more than the amount given here.+ --+ -- This number should be a non-negative integer.++ , postingsPayeeAllocation = 40+ -- ^ postingsPayeeAllocation and postingsAccountAllocation+ -- determine how much space is allotted to the payee and account+ -- fields in the postings report. These fields are variable+ -- width. After space for most other fields is allotted, space is+ -- allotted for these two fields. The two fields divide the space+ -- proportionally depending on postingsPayeeAllocation and+ -- postingsAccountAllocation. For example, if+ -- postingsPayeeAllocation is 60 and postingsAccountAllocation is+ -- 40, then the payee field gets 60 percent of the leftover space+ -- and the account field gets 40 percent of the leftover space.+ --+ -- Both postingsPayeeAllocation and postingsAccountAllocation+ -- must be positive integers; if either one is less than 1, your+ -- program will crash at runtime.++ , postingsAccountAllocation = 60+ -- ^ See postingsPayeeAllocation above for an explanation++ , postingsSpacers = spacers+ -- ^ Determines the number of spaces that appears to the right of+ -- each named field; for example, sPayee indicates how many spaces+ -- will appear to the right of the payee field. Each field of the+ -- Spacers should be a non-negative integer (although currently+ -- the absolute value of the field is taken.)+ }++-- | Controls which fields appear in the report by default.+fields :: Fields Bool+fields = Fields+ { fGlobalTransaction = False+ , fRevGlobalTransaction = False+ , fGlobalPosting = False+ , fRevGlobalPosting = False+ , fFileTransaction = False+ , fRevFileTransaction = False+ , fFilePosting = False+ , fRevFilePosting = False+ , fFiltered = False+ , fRevFiltered = False+ , fSorted = False+ , fRevSorted = False+ , fVisible = False+ , fRevVisible = False+ , fLineNum = False+ , fDate = True+ , fFlag = False+ , fNumber = False+ , fPayee = True+ , fAccount = True+ , fPostingDrCr = True+ , fPostingCmdty = True+ , fPostingQty = True+ , fTotalDrCr = True+ , fTotalCmdty = True+ , fTotalQty = True+ , fTags = False+ , fMemo = False+ , fFilename = False+ }++-- | Controls how many spaces appear to the right of each named field.+spacers :: Spacers Int+spacers = Spacers+ { sGlobalTransaction = 1+ , sRevGlobalTransaction = 1+ , sGlobalPosting = 1+ , sRevGlobalPosting = 1+ , sFileTransaction = 1+ , sRevFileTransaction = 1+ , sFilePosting = 1+ , sRevFilePosting = 1+ , sFiltered = 1+ , sRevFiltered = 1+ , sSorted = 1+ , sRevSorted = 1+ , sVisible = 1+ , sRevVisible = 1+ , sLineNum = 1+ , sDate = 1+ , sFlag = 1+ , sNumber = 1+ , sPayee = 4+ , sAccount = 1+ , sPostingDrCr = 1+ , sPostingCmdty = 1+ , sPostingQty = 1+ , sTotalDrCr = 1+ , sTotalCmdty = 1+ }++-- | The light color scheme. You can change various values below to+-- affect the color scheme.+schemeLight :: Scheme+schemeLight = Scheme "light" "for light background terminals"+ lightLabels++lightLabels :: Labels (EvenAndOdd TextSpec)+lightLabels = Labels+ { debit = EvenAndOdd { eoEven = lightDebit lightEvenTextSpec+ , eoOdd = lightDebit lightOddTextSpec }+ , credit = EvenAndOdd { eoEven = lightCredit lightEvenTextSpec+ , eoOdd = lightCredit lightOddTextSpec }+ , zero = EvenAndOdd { eoEven = lightZero lightEvenTextSpec+ , eoOdd = lightZero lightOddTextSpec }+ , other = EvenAndOdd { eoEven = lightEvenTextSpec+ , eoOdd = lightOddTextSpec }+ }++lightEvenTextSpec :: TextSpec+lightEvenTextSpec = defaultTextSpec++lightOddTextSpec :: TextSpec+lightOddTextSpec = switchBackground color8_b_default+ color256_b_255 lightEvenTextSpec++lightDebit :: TextSpec -> TextSpec+lightDebit = switchForeground color8_f_magenta color256_f_52++lightCredit :: TextSpec -> TextSpec+lightCredit = switchForeground color8_f_cyan color256_f_21++lightZero :: TextSpec -> TextSpec+lightZero = switchForeground color8_f_black color256_f_0++-- | The dark color scheme. You can change various values below to+-- affect the color scheme.+schemeDark :: Scheme+schemeDark = Scheme "dark" "for dark background terminals"+ darkLabels++darkLabels :: Labels (EvenAndOdd TextSpec)+darkLabels = Labels+ { debit = EvenAndOdd { eoEven = darkDebit darkEvenTextSpec+ , eoOdd = darkDebit darkOddTextSpec }+ , credit = EvenAndOdd { eoEven = darkCredit darkEvenTextSpec+ , eoOdd = darkCredit darkOddTextSpec }+ , zero = EvenAndOdd { eoEven = darkZero darkEvenTextSpec+ , eoOdd = darkZero darkOddTextSpec }+ , other = EvenAndOdd { eoEven = darkEvenTextSpec+ , eoOdd = darkOddTextSpec }+ }++darkEvenTextSpec :: TextSpec+darkEvenTextSpec = defaultTextSpec++darkOddTextSpec :: TextSpec+darkOddTextSpec = switchBackground color8_b_default+ color256_b_235 darkEvenTextSpec++darkDebit :: TextSpec -> TextSpec+darkDebit = switchForeground color8_f_magenta color256_f_208++darkCredit :: TextSpec -> TextSpec+darkCredit = switchForeground color8_f_cyan color256_f_45++darkZero :: TextSpec -> TextSpec+darkZero = switchForeground color8_f_white color256_f_15++-- | Plain scheme has no colors at all.+schemePlain :: Scheme+schemePlain = Scheme "plain" "uses default terminal colors"+ plainLabels++plainLabels :: Labels (EvenAndOdd TextSpec)+plainLabels = Labels+ { debit = EvenAndOdd defaultTextSpec defaultTextSpec+ , credit = EvenAndOdd defaultTextSpec defaultTextSpec+ , zero = EvenAndOdd defaultTextSpec defaultTextSpec+ , other = EvenAndOdd defaultTextSpec defaultTextSpec+ }++main :: IO ()+main = runPenny defaults+
− penny.hs
@@ -1,295 +0,0 @@-module Main where--import Penny---- | This type contains settings for all the reports, as well as--- default settings for the global options. Some of these can be--- overridden on the command line.-defaults :: Runtime -> Defaults-defaults rt = Defaults- { caseSensitive = False- -- ^ Whether the matcher is case sensitive by default-- , matcher = Within- -- ^ Which matcher to use. Your choices:- -- Within- -- Exact- -- TDFA (regular expressions, POSIX semantics)- -- PCRE (regular expressions, PCRE semantics)-- , colorToFile = False- -- ^ Use colors when standard output is not a terminal?-- , defaultScheme = Just schemeDark- -- ^ Default color scheme. If Nothing, there is no default color- -- scheme. If there is no default color scheme and the user does- -- not pick one on the command line, no colors will be used.-- , additionalSchemes = [schemeDark, schemeLight, schemePlain]- -- ^ Additional color schemes the user can pick from on the- -- command line.-- , sorter = [(Date, Ascending)]- -- ^ Postings are sorted in this order by default. For example, if- -- the first pair is (Date, Ascending), then postings are first- -- sorted by date in ascending order. If the second pair is- -- (Payee, Ascending), then postings with the same date are then- -- sorted by payee.- --- -- If this list is empty, then by default postings are left in the- -- same order as they appear in the ledger files.-- , balanceFormat = const defaultQtyFormat- -- ^ How to format balances in the balance report. Change this- -- function if, for example, you want to allow for digit- -- grouping. The default function does not perform digit grouping.-- , balanceShowZeroBalances = False- -- ^ Show zero balances in the balance report? If True, show them;- -- if False, hide them.-- , balanceOrder = Ascending- -- ^ Whether to sort the accounts in ascending or descending order- -- by account name in the balance report. Your choices: Ascending- -- or Descending.-- , convertShowZeroBalances = False- -- ^ Show zero balances in the convert report? If True, show them;- -- if False, hide them.-- , convertTarget = AutoTarget- -- ^ The commodity to which to convert the commodities in the- -- convert report. Your choices:- --- -- AutoTarget - selects a target commodity automatically, based on- -- which commodity is the most common target commodity in the- -- prices in your ledger files. If there is a tie for most common- -- target commodity, the target that appears later in your ledger- -- files is used.- --- -- ManualTarget CMDTY_NAME - always use the given commodity.-- , convertOrder = Ascending- -- ^ Sort the convert report in ascending or descending order.-- , convertSortBy = SortByName- -- ^ Sort by account or by quantity in the convert report. Your- -- choices:- --- -- SortByQty- -- SortByName-- , convertFormat = const defaultQtyFormat- -- ^ How to format balances in the convert report. For instance,- -- this function might perform digit grouping. The default- -- function does not perform any digit grouping.-- , postingsFields = fields- -- ^ Fields to show by default in the postings report.-- , postingsWidth = widthFromRuntime rt- -- ^ The postings report is roughly this wide by default. Use- -- @widthFromRuntime rt@ if you want to use the current width of- -- your terminal.-- , postingsShowZeroBalances = False- -- ^ Show zero balances in the postings report? If True, show- -- them; if False, hide them.-- , postingsDateFormat = yearMonthDay- -- ^ How to format dates in the postings report.-- , postingsQtyFormat = qtyAsIs- -- ^ How to format quantities in the balance report. This function- -- is used when showing the quantity for the posting itself, and- -- not the quantity for the totals columns (for that, see- -- postingsBalanceFormat.) For example this function might perform- -- digit grouping.-- , postingsBalanceFormat = balanceAsIs- -- ^ How to format balance totals in the postings report.-- , postingsSubAccountLength = 2- -- ^ Account names in the postings report are shortened if- -- necessary in order to help the report fit within the allotted- -- width (see postingsWidth). Account names are only shortened as- -- much as is necessary for them to fit; however, each sub-account- -- name will not be shortened any more than the amount given here.- --- -- This number should be a non-negative integer.-- , postingsPayeeAllocation = 40- -- ^ postingsPayeeAllocation and postingsAccountAllocation- -- determine how much space is allotted to the payee and account- -- fields in the postings report. These fields are variable- -- width. After space for most other fields is allotted, space is- -- allotted for these two fields. The two fields divide the space- -- proportionally depending on postingsPayeeAllocation and- -- postingsAccountAllocation. For example, if- -- postingsPayeeAllocation is 60 and postingsAccountAllocation is- -- 40, then the payee field gets 60 percent of the leftover space- -- and the account field gets 40 percent of the leftover space.- --- -- Both postingsPayeeAllocation and postingsAccountAllocation- -- must be positive integers; if either one is less than 1, your- -- program will crash at runtime.-- , postingsAccountAllocation = 60- -- ^ See postingsPayeeAllocation above for an explanation-- , postingsSpacers = spacers- -- ^ Determines the number of spaces that appears to the right of- -- each named field; for example, sPayee indicates how many spaces- -- will appear to the right of the payee field. Each field of the- -- Spacers should be a non-negative integer (although currently- -- the absolute value of the field is taken.)- }---- | Controls which fields appear in the report by default.-fields :: Fields Bool-fields = Fields- { fGlobalTransaction = False- , fRevGlobalTransaction = False- , fGlobalPosting = False- , fRevGlobalPosting = False- , fFileTransaction = False- , fRevFileTransaction = False- , fFilePosting = False- , fRevFilePosting = False- , fFiltered = False- , fRevFiltered = False- , fSorted = False- , fRevSorted = False- , fVisible = False- , fRevVisible = False- , fLineNum = False- , fDate = True- , fFlag = False- , fNumber = False- , fPayee = True- , fAccount = True- , fPostingDrCr = True- , fPostingCmdty = True- , fPostingQty = True- , fTotalDrCr = True- , fTotalCmdty = True- , fTotalQty = True- , fTags = False- , fMemo = False- , fFilename = False- }---- | Controls how many spaces appear to the right of each named field.-spacers :: Spacers Int-spacers = Spacers- { sGlobalTransaction = 1- , sRevGlobalTransaction = 1- , sGlobalPosting = 1- , sRevGlobalPosting = 1- , sFileTransaction = 1- , sRevFileTransaction = 1- , sFilePosting = 1- , sRevFilePosting = 1- , sFiltered = 1- , sRevFiltered = 1- , sSorted = 1- , sRevSorted = 1- , sVisible = 1- , sRevVisible = 1- , sLineNum = 1- , sDate = 1- , sFlag = 1- , sNumber = 1- , sPayee = 4- , sAccount = 1- , sPostingDrCr = 1- , sPostingCmdty = 1- , sPostingQty = 1- , sTotalDrCr = 1- , sTotalCmdty = 1- }---- | The light color scheme. You can change various values below to--- affect the color scheme.-schemeLight :: Scheme-schemeLight = Scheme "light" "for light background terminals"- lightLabels--lightLabels :: Labels (EvenAndOdd TextSpec)-lightLabels = Labels- { debit = EvenAndOdd { eoEven = lightDebit lightEvenTextSpec- , eoOdd = lightDebit lightOddTextSpec }- , credit = EvenAndOdd { eoEven = lightCredit lightEvenTextSpec- , eoOdd = lightCredit lightOddTextSpec }- , zero = EvenAndOdd { eoEven = lightZero lightEvenTextSpec- , eoOdd = lightZero lightOddTextSpec }- , other = EvenAndOdd { eoEven = lightEvenTextSpec- , eoOdd = lightOddTextSpec }- }--lightEvenTextSpec :: TextSpec-lightEvenTextSpec = defaultTextSpec--lightOddTextSpec :: TextSpec-lightOddTextSpec = switchBackground color8_b_default- color256_b_255 lightEvenTextSpec--lightDebit :: TextSpec -> TextSpec-lightDebit = switchForeground color8_f_magenta color256_f_52--lightCredit :: TextSpec -> TextSpec-lightCredit = switchForeground color8_f_cyan color256_f_21--lightZero :: TextSpec -> TextSpec-lightZero = switchForeground color8_f_black color256_f_0---- | The dark color scheme. You can change various values below to--- affect the color scheme.-schemeDark :: Scheme-schemeDark = Scheme "dark" "for dark background terminals"- darkLabels--darkLabels :: Labels (EvenAndOdd TextSpec)-darkLabels = Labels- { debit = EvenAndOdd { eoEven = darkDebit darkEvenTextSpec- , eoOdd = darkDebit darkOddTextSpec }- , credit = EvenAndOdd { eoEven = darkCredit darkEvenTextSpec- , eoOdd = darkCredit darkOddTextSpec }- , zero = EvenAndOdd { eoEven = darkZero darkEvenTextSpec- , eoOdd = darkZero darkOddTextSpec }- , other = EvenAndOdd { eoEven = darkEvenTextSpec- , eoOdd = darkOddTextSpec }- }--darkEvenTextSpec :: TextSpec-darkEvenTextSpec = defaultTextSpec--darkOddTextSpec :: TextSpec-darkOddTextSpec = switchBackground color8_b_default- color256_b_235 darkEvenTextSpec--darkDebit :: TextSpec -> TextSpec-darkDebit = switchForeground color8_f_magenta color256_f_208--darkCredit :: TextSpec -> TextSpec-darkCredit = switchForeground color8_f_cyan color256_f_45--darkZero :: TextSpec -> TextSpec-darkZero = switchForeground color8_f_white color256_f_15---- | Plain scheme has no colors at all.-schemePlain :: Scheme-schemePlain = Scheme "plain" "uses default terminal colors"- plainLabels--plainLabels :: Labels (EvenAndOdd TextSpec)-plainLabels = Labels- { debit = EvenAndOdd defaultTextSpec defaultTextSpec- , credit = EvenAndOdd defaultTextSpec defaultTextSpec- , zero = EvenAndOdd defaultTextSpec defaultTextSpec- , other = EvenAndOdd defaultTextSpec defaultTextSpec- }--main :: IO ()-main = runPenny defaults-