cli: command to list included files
This commit is contained in:
parent
3de8c11de1
commit
cb979ed129
@ -278,6 +278,7 @@ standardAddonsHelp = [
|
|||||||
,("vty", "start the curses-style interface")
|
,("vty", "start the curses-style interface")
|
||||||
,("web", "start the web interface")
|
,("web", "start the web interface")
|
||||||
,("accounts", "list account names")
|
,("accounts", "list account names")
|
||||||
|
,("files", "list included files")
|
||||||
,("balance-csv", "output a balance report as CSV")
|
,("balance-csv", "output a balance report as CSV")
|
||||||
,("close", "show a transaction entry zeroing all accounts")
|
,("close", "show a transaction entry zeroing all accounts")
|
||||||
,("print-unique", "print only transactions with unique descriptions")
|
,("print-unique", "print only transactions with unique descriptions")
|
||||||
|
|||||||
@ -64,6 +64,7 @@ import Hledger.Cli.Commands.Cashflow
|
|||||||
import Hledger.Cli.Commands.Checkdates
|
import Hledger.Cli.Commands.Checkdates
|
||||||
import Hledger.Cli.Commands.Checkdupes
|
import Hledger.Cli.Commands.Checkdupes
|
||||||
import Hledger.Cli.Commands.Close
|
import Hledger.Cli.Commands.Close
|
||||||
|
import Hledger.Cli.Commands.Files
|
||||||
import Hledger.Cli.Commands.Help
|
import Hledger.Cli.Commands.Help
|
||||||
import Hledger.Cli.Commands.Import
|
import Hledger.Cli.Commands.Import
|
||||||
import Hledger.Cli.Commands.Incomestatement
|
import Hledger.Cli.Commands.Incomestatement
|
||||||
@ -93,6 +94,7 @@ builtinCommands = [
|
|||||||
,(closemode , close)
|
,(closemode , close)
|
||||||
,(helpmode , help')
|
,(helpmode , help')
|
||||||
,(importmode , importcmd)
|
,(importmode , importcmd)
|
||||||
|
,(filesmode , files)
|
||||||
,(incomestatementmode , incomestatement)
|
,(incomestatementmode , incomestatement)
|
||||||
,(pricesmode , prices)
|
,(pricesmode , prices)
|
||||||
,(printmode , print')
|
,(printmode , print')
|
||||||
|
|||||||
48
hledger/Hledger/Cli/Commands/Files.hs
Normal file
48
hledger/Hledger/Cli/Commands/Files.hs
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
{-|
|
||||||
|
|
||||||
|
The @files@ command lists included files.
|
||||||
|
|
||||||
|
-}
|
||||||
|
|
||||||
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
|
|
||||||
|
module Hledger.Cli.Commands.Files (
|
||||||
|
filesmode
|
||||||
|
,files
|
||||||
|
) where
|
||||||
|
|
||||||
|
import Data.List
|
||||||
|
-- import Data.Text (Text)
|
||||||
|
import Safe
|
||||||
|
import System.Console.CmdArgs.Explicit as C
|
||||||
|
|
||||||
|
import Hledger
|
||||||
|
import Prelude hiding (putStrLn)
|
||||||
|
import Hledger.Utils.UTF8IOCompat (putStrLn)
|
||||||
|
import Hledger.Cli.CliOptions
|
||||||
|
|
||||||
|
|
||||||
|
-- | Command line options for this command.
|
||||||
|
filesmode = (defCommandMode $ ["files"] ) {
|
||||||
|
modeHelp = "show names of included files"
|
||||||
|
,modeHelpSuffix = [
|
||||||
|
"This command lists names of all files included in the parsed journal(s)."
|
||||||
|
,"With REGEX argument will list only files matching regular expression (case sensitive)."
|
||||||
|
]
|
||||||
|
,modeGroupFlags = C.Group {
|
||||||
|
groupUnnamed = []
|
||||||
|
,groupHidden = []
|
||||||
|
,groupNamed = [generalflagsgroup2]
|
||||||
|
}
|
||||||
|
,modeArgs= ([], Just $ argsFlag "[REGEX]")
|
||||||
|
}
|
||||||
|
|
||||||
|
-- | The files command.
|
||||||
|
files :: CliOpts -> Journal -> IO ()
|
||||||
|
files CliOpts{rawopts_=rawopts} j = do
|
||||||
|
let args = listofstringopt "args" rawopts
|
||||||
|
regex = headMay args
|
||||||
|
files = (maybe id (filter . regexMatches) regex)
|
||||||
|
$ map fst
|
||||||
|
$ jfiles j
|
||||||
|
mapM_ putStrLn files
|
||||||
@ -368,6 +368,10 @@ or for closing out income/expenses for a period.
|
|||||||
This was formerly called "equity", as in Ledger, and that alias is also accepted.
|
This was formerly called "equity", as in Ledger, and that alias is also accepted.
|
||||||
See close --help for more.
|
See close --help for more.
|
||||||
|
|
||||||
|
## files
|
||||||
|
List all files included in the journal. With a REGEX argument,
|
||||||
|
only file names matching the regular expression (case sensitive) are shown.
|
||||||
|
|
||||||
## help
|
## help
|
||||||
Show any of the hledger manuals.
|
Show any of the hledger manuals.
|
||||||
|
|
||||||
|
|||||||
@ -140,6 +140,7 @@ library:
|
|||||||
- Hledger.Cli.Commands.Checkdupes
|
- Hledger.Cli.Commands.Checkdupes
|
||||||
- Hledger.Cli.Commands.Close
|
- Hledger.Cli.Commands.Close
|
||||||
- Hledger.Cli.Commands.Help
|
- Hledger.Cli.Commands.Help
|
||||||
|
- Hledger.Cli.Commands.Files
|
||||||
- Hledger.Cli.Commands.Import
|
- Hledger.Cli.Commands.Import
|
||||||
- Hledger.Cli.Commands.Incomestatement
|
- Hledger.Cli.Commands.Incomestatement
|
||||||
- Hledger.Cli.Commands.Prices
|
- Hledger.Cli.Commands.Prices
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user