commodities: add commodities command
This commit is contained in:
		
							parent
							
								
									9e3cdef1e9
								
							
						
					
					
						commit
						d7a815fc08
					
				| @ -27,6 +27,7 @@ module Hledger.Cli.Commands ( | ||||
|   ,module Hledger.Cli.Commands.Checkdates | ||||
|   ,module Hledger.Cli.Commands.Checkdupes | ||||
|   ,module Hledger.Cli.Commands.Close | ||||
|   ,module Hledger.Cli.Commands.Commodities | ||||
|   ,module Hledger.Cli.Commands.Help | ||||
|   ,module Hledger.Cli.Commands.Import | ||||
|   ,module Hledger.Cli.Commands.Incomestatement | ||||
| @ -67,6 +68,7 @@ import Hledger.Cli.Commands.Cashflow | ||||
| import Hledger.Cli.Commands.Checkdates | ||||
| import Hledger.Cli.Commands.Checkdupes | ||||
| import Hledger.Cli.Commands.Close | ||||
| import Hledger.Cli.Commands.Commodities | ||||
| import Hledger.Cli.Commands.Files | ||||
| import Hledger.Cli.Commands.Help | ||||
| import Hledger.Cli.Commands.Import | ||||
| @ -96,6 +98,7 @@ builtinCommands = [ | ||||
|   ,(checkdatesmode         , checkdates) | ||||
|   ,(checkdupesmode         , checkdupes) | ||||
|   ,(closemode              , close) | ||||
|   ,(commoditiesmode        , commodities) | ||||
|   ,(helpmode               , help') | ||||
|   ,(importmode             , importcmd) | ||||
|   ,(filesmode              , files) | ||||
| @ -164,6 +167,7 @@ commandsList = unlines [ | ||||
|   ," accounts (a)             show account names" | ||||
|   ," activity                 show postings-per-interval bar charts" | ||||
|   ," balance (b, bal)         show balance changes/end balances/budgets in accounts" | ||||
|   ," commodities              show commodity/currency symbols" | ||||
|   ," files                    show input file paths" | ||||
|   ," prices                   show market price records" | ||||
|   ," print (p, txns)          show transactions (journal entries)" | ||||
|  | ||||
							
								
								
									
										36
									
								
								hledger/Hledger/Cli/Commands/Commodities.hs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								hledger/Hledger/Cli/Commands/Commodities.hs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,36 @@ | ||||
| {-| | ||||
| 
 | ||||
| The @commodities@ command lists commodity/currency symbols. | ||||
| 
 | ||||
| -} | ||||
| 
 | ||||
| {-# LANGUAGE OverloadedStrings #-} | ||||
| {-# LANGUAGE TemplateHaskell #-} | ||||
| 
 | ||||
| module Hledger.Cli.Commands.Commodities ( | ||||
|   commoditiesmode | ||||
|  ,commodities | ||||
| ) where | ||||
| 
 | ||||
| import Control.Monad | ||||
| import Data.List | ||||
| import qualified Data.Map as M | ||||
| import qualified Data.Text.IO as T | ||||
| 
 | ||||
| import Hledger | ||||
| import Hledger.Cli.CliOptions | ||||
| 
 | ||||
| 
 | ||||
| -- | Command line options for this command. | ||||
| commoditiesmode = hledgerCommandMode | ||||
|   ($(embedFileRelative "Hledger/Cli/Commands/Commodities.txt")) | ||||
|   [] | ||||
|   [generalflagsgroup2] | ||||
|   [] | ||||
|   ([], Nothing) | ||||
| 
 | ||||
| commodities :: CliOpts -> Journal -> IO () | ||||
| commodities _copts j = do | ||||
|   let cs = filter (/= "AUTO") $ | ||||
|            nub $ sort $ M.keys (jcommodities j) ++ M.keys (jinferredcommodities j) | ||||
|   forM_ cs T.putStrLn | ||||
							
								
								
									
										4
									
								
								hledger/Hledger/Cli/Commands/Commodities.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								hledger/Hledger/Cli/Commands/Commodities.md
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,4 @@ | ||||
| commodities\ | ||||
| List all commodity/currency symbols used or declared in the journal. | ||||
| 
 | ||||
| _FLAGS_ | ||||
							
								
								
									
										4
									
								
								hledger/Hledger/Cli/Commands/Commodities.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								hledger/Hledger/Cli/Commands/Commodities.txt
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,4 @@ | ||||
| commodities | ||||
| List all commodity/currency symbols used or declared in the journal. | ||||
| 
 | ||||
| _FLAGS_ | ||||
| @ -4,7 +4,7 @@ cabal-version: 1.12 | ||||
| -- | ||||
| -- see: https://github.com/sol/hpack | ||||
| -- | ||||
| -- hash: 23816762c7f1abc912788cda07079f28217cdf0638286735e84cfa4f5a24ca2e | ||||
| -- hash: 837fc1f3539c3f3c9f0eb1cbde0b6b361836e7f8c2a8c7cefaaa7f626f17658e | ||||
| 
 | ||||
| name:           hledger | ||||
| version:        1.13.99 | ||||
| @ -119,6 +119,7 @@ library | ||||
|       Hledger.Cli.Commands.Checkdates | ||||
|       Hledger.Cli.Commands.Checkdupes | ||||
|       Hledger.Cli.Commands.Close | ||||
|       Hledger.Cli.Commands.Commodities | ||||
|       Hledger.Cli.Commands.Help | ||||
|       Hledger.Cli.Commands.Files | ||||
|       Hledger.Cli.Commands.Import | ||||
|  | ||||
| @ -163,6 +163,7 @@ library: | ||||
|   - Hledger.Cli.Commands.Checkdates | ||||
|   - Hledger.Cli.Commands.Checkdupes | ||||
|   - Hledger.Cli.Commands.Close | ||||
|   - Hledger.Cli.Commands.Commodities | ||||
|   - Hledger.Cli.Commands.Help | ||||
|   - Hledger.Cli.Commands.Files | ||||
|   - Hledger.Cli.Commands.Import | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user