May also fix #1154, #1033, #708, #536, #73: testing is needed. This aims to solve all problems where misconfigured locales lead to parsers failing on utf8-encoded data. This should hopefully avoid encoding issues, but since it fundamentally alters how encoding is dealt with it may lead to unexpected outcomes. Widespread testing on a number of different platforms would be useful.
		
			
				
	
	
		
			39 lines
		
	
	
		
			929 B
		
	
	
	
		
			Haskell
		
	
	
	
	
	
			
		
		
	
	
			39 lines
		
	
	
		
			929 B
		
	
	
	
		
			Haskell
		
	
	
	
	
	
| {-|
 | |
| 
 | |
| The @notes@ command lists all unique notes (description part after a |) seen in transactions, sorted alphabetically.
 | |
| 
 | |
| -}
 | |
| 
 | |
| {-# LANGUAGE MultiWayIf #-}
 | |
| {-# LANGUAGE OverloadedStrings #-}
 | |
| {-# LANGUAGE ScopedTypeVariables #-}
 | |
| {-# LANGUAGE TemplateHaskell #-}
 | |
| {-# LANGUAGE CPP #-}
 | |
| 
 | |
| module Hledger.Cli.Commands.Notes (
 | |
|   notesmode
 | |
|  ,notes
 | |
| ) where
 | |
| 
 | |
| import Data.List.Extra (nubSort)
 | |
| import qualified Data.Text.IO as TIO (putStrLn)  -- Only putStr and friends are safe
 | |
| 
 | |
| import Hledger
 | |
| import Hledger.Cli.CliOptions
 | |
| 
 | |
| 
 | |
| -- | Command line options for this command.
 | |
| notesmode = hledgerCommandMode
 | |
|   $(embedFileRelative "Hledger/Cli/Commands/Notes.txt")
 | |
|   []
 | |
|   [generalflagsgroup1]
 | |
|   hiddenflags
 | |
|   ([], Just $ argsFlag "[QUERY]")
 | |
| 
 | |
| -- | The notes command.
 | |
| notes :: CliOpts -> Journal -> IO ()
 | |
| notes CliOpts{reportspec_=rspec} j = do
 | |
|   let ts = entriesReport rspec j
 | |
|       notes = nubSort $ map transactionNote ts
 | |
|   mapM_ TIO.putStrLn notes
 |