mirror of
https://github.com/simonmichael/hledger.git
synced 2024-09-19 18:29:36 +03:00
33 lines
1.1 KiB
Haskell
33 lines
1.1 KiB
Haskell
|
#!/usr/bin/env stack
|
||
|
-- stack script --compile --resolver nightly-2020-03-26 --package hledger-lib --package hledger --package directory --package text
|
||
|
-- Add this to see more progress: --verbosity info
|
||
|
-- Change --resolver to an already-installed one if you like
|
||
|
|
||
|
-- Read the default journal and give an error if any tag values
|
||
|
-- containing '/' do not exist as file paths. Usage:
|
||
|
--
|
||
|
-- $ hledger-check-tag-files.hs # compiles if needed
|
||
|
--
|
||
|
-- or:
|
||
|
--
|
||
|
-- $ hledger check-tag-files # compiles if there's no compiled version
|
||
|
|
||
|
import Control.Monad
|
||
|
import qualified Data.Text as T
|
||
|
import Hledger.Cli
|
||
|
import System.Directory
|
||
|
import System.Exit
|
||
|
|
||
|
main = withJournalDo defcliopts $ \j -> do
|
||
|
let filetags = [ (t,v)
|
||
|
| (t',v') <- concatMap transactionAllTags $ jtxns j
|
||
|
, let t = T.unpack t'
|
||
|
, let v = T.unpack v'
|
||
|
, '/' `elem` v
|
||
|
]
|
||
|
forM_ filetags $ \(t,f) -> do
|
||
|
exists <- doesFileExist f
|
||
|
when (not exists) $ do
|
||
|
putStrLn $ "file not found in tag: " ++ t ++ ": " ++ f
|
||
|
exitFailure
|