hledger-balance-csv, hledger-print-csv: remove
This commit is contained in:
		
							parent
							
								
									b6774f47a3
								
							
						
					
					
						commit
						827aaad08e
					
				| @ -1,30 +0,0 @@ | |||||||
| #!/usr/bin/env runhaskell |  | ||||||
| {-| |  | ||||||
| hledger-balance-csv [OPTIONS] [ARGS] |  | ||||||
| 
 |  | ||||||
| Show a balance report as CSV. |  | ||||||
| -} |  | ||||||
| 
 |  | ||||||
| import Hledger.Cli |  | ||||||
| import Text.CSV |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| argsmode = |  | ||||||
|   (defCommandMode ["balance-csv"]) { |  | ||||||
|      modeHelp = "show matched postings accounts and their balances as CSV" |  | ||||||
|     ,modeGroupFlags = Group { |  | ||||||
|        groupNamed = [] |  | ||||||
|       ,groupUnnamed = inputflags ++ reportflags ++ helpflags |  | ||||||
|       ,groupHidden = [] |  | ||||||
|       } |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
| main = getCliOpts argsmode >>= printBalanceCsv |  | ||||||
| 
 |  | ||||||
| printBalanceCsv opts = withJournalDo opts $ |  | ||||||
|   \CliOpts{reportopts_=ropts} j -> do |  | ||||||
|     d <- getCurrentDay |  | ||||||
|     let (items,_) = balanceReport ropts (queryFromOpts d ropts) j |  | ||||||
|     putStrLn $ printCSV $ |  | ||||||
|       ["account","balance"] : |  | ||||||
|       [[a, showMixedAmountWithoutPrice b] | ((a, _, _), b) <- items] |  | ||||||
| @ -1,74 +0,0 @@ | |||||||
| #!/usr/bin/env runhaskell |  | ||||||
| {-| |  | ||||||
| hledger-print-csv [-f JOURNALFILE] |  | ||||||
| 
 |  | ||||||
| Print matched journal entries as CSV |  | ||||||
| Reads the default or specified journal. |  | ||||||
| |-} |  | ||||||
| 
 |  | ||||||
| import Hledger.Cli |  | ||||||
| import Text.CSV |  | ||||||
| import Data.Char (isSpace) |  | ||||||
| import Data.List (mapAccumL) |  | ||||||
| 
 |  | ||||||
| argsmode :: Mode RawOpts |  | ||||||
| argsmode = (defCommandMode ["print-csv"]) |  | ||||||
| 	{ modeHelp = "print matched journal entries as CSV" |  | ||||||
| 	, modeGroupFlags = Group |  | ||||||
| 		{ groupNamed = |  | ||||||
| 			[ ("Input",inputflags) |  | ||||||
| 			, ("Reporting",reportflags) |  | ||||||
| 			, ("Misc",helpflags) |  | ||||||
| 			] |  | ||||||
| 		, groupUnnamed = [] |  | ||||||
| 		, groupHidden = [] |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| chomp :: String -> String |  | ||||||
| chomp = reverse . dropWhile isSpace . reverse . dropWhile isSpace |  | ||||||
| 
 |  | ||||||
| postingToCSV :: Posting -> CSV |  | ||||||
| postingToCSV p = |  | ||||||
| 	map (\(a@(Amount {aquantity=q,acommodity=c})) -> |  | ||||||
| 		let a_ = a{acommodity=""} in |  | ||||||
| 		let amount = showAmount a_ in |  | ||||||
| 		let commodity = c in |  | ||||||
| 		let credit = if q < 0 then showAmount $ negate a_ else "" in |  | ||||||
| 		let debit  = if q > 0 then showAmount a_ else "" in |  | ||||||
| 		account:amount:commodity:credit:debit:status:comment:[]) |  | ||||||
| 	 amounts |  | ||||||
| 	where |  | ||||||
| 		Mixed amounts = pamount p |  | ||||||
| 		status = if pstatus p then "*" else "" |  | ||||||
| 		account = showAccountName Nothing (ptype p) (paccount p) |  | ||||||
| 		comment = chomp $ pcomment p |  | ||||||
| 
 |  | ||||||
| postingsToCSV :: [Posting] -> CSV |  | ||||||
| postingsToCSV ps = |  | ||||||
| 	concatMap postingToCSV ps |  | ||||||
| 
 |  | ||||||
| transactionToCSV :: Integer -> Transaction -> CSV |  | ||||||
| transactionToCSV n t = |  | ||||||
| 	map (\p -> show n:date:date2:status:code:description:comment:p) |  | ||||||
| 	 (postingsToCSV (tpostings t)) |  | ||||||
| 	where |  | ||||||
| 		description = tdescription t |  | ||||||
| 		date = showDate (tdate t) |  | ||||||
| 		date2 = maybe "" showDate (tdate2 t) |  | ||||||
| 		status = if tstatus t then "*" else "" |  | ||||||
| 		code = tcode t |  | ||||||
| 		comment = chomp $ tcomment t |  | ||||||
| 
 |  | ||||||
| main :: IO () |  | ||||||
| main = do |  | ||||||
| 	opts <- getCliOpts argsmode |  | ||||||
| 	withJournalDo opts $ |  | ||||||
| 	 \CliOpts{reportopts_=ropts} j -> do |  | ||||||
| 		d <- getCurrentDay |  | ||||||
| 		let ropts_ = ropts{flat_=True} |  | ||||||
| 		let q = queryFromOpts d ropts_ |  | ||||||
| 		putStrLn $ printCSV $ concat $ |  | ||||||
| 			([["nth","date","date2","status","code","description","comment","account","amount","commodity","credit","debit","status","posting-comment"]]:).snd $ |  | ||||||
| 				mapAccumL (\n e -> (n + 1, transactionToCSV n e)) 0 $ |  | ||||||
| 					entriesReport ropts_ q j |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user