fix: bin: Get hledger-print-location working.
This commit is contained in:
parent
19ed6d3f00
commit
852ba7b100
@ -19,8 +19,7 @@ $ hledger print-location -f examples/sample.journal desc:eat
|
|||||||
{-# LANGUAGE QuasiQuotes #-}
|
{-# LANGUAGE QuasiQuotes #-}
|
||||||
|
|
||||||
import Data.String.QQ (s)
|
import Data.String.QQ (s)
|
||||||
import Data.Text (pack)
|
import qualified Data.Text as T
|
||||||
import Text.Printf
|
|
||||||
import Hledger.Cli
|
import Hledger.Cli
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
@ -44,9 +43,8 @@ main = do
|
|||||||
addLocationTag :: Transaction -> Transaction
|
addLocationTag :: Transaction -> Transaction
|
||||||
addLocationTag t = t{tcomment = tcomment t `commentAddTagNextLine` loctag}
|
addLocationTag t = t{tcomment = tcomment t `commentAddTagNextLine` loctag}
|
||||||
where
|
where
|
||||||
loctag = ("location", pack $ showGenericSourcePosLine $ tsourcepos t)
|
loctag = ("location", T.pack . showSourcePosPair $ tsourcepos t)
|
||||||
|
|
||||||
-- Like showGenericSourcePos in Hledger.Data.Transaction, but show just the starting line number.
|
-- Like showSourcePosPair in Hledger.Data.Transaction, but show just the starting line number.
|
||||||
showGenericSourcePosLine :: GenericSourcePos -> String
|
showSourcePosPairLine :: (SourcePos, SourcePos) -> String
|
||||||
showGenericSourcePosLine (GenericSourcePos f line _) = printf "%s:%d" f line
|
showSourcePosPairLine (SourcePos f line _, _) = f ++ ":" ++ show line
|
||||||
showGenericSourcePosLine (JournalSourcePos f (startline, _)) = printf "%s:%d" f startline
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user