imp:close: omit file extension from tag value
This commit is contained in:
parent
bde97b8f28
commit
87cc3e1393
@ -19,7 +19,7 @@ import System.Console.CmdArgs.Explicit as C
|
||||
import Hledger
|
||||
import Hledger.Cli.CliOptions
|
||||
import Safe (lastDef, readMay, readDef)
|
||||
import System.FilePath (takeFileName)
|
||||
import System.FilePath (takeBaseName)
|
||||
import Data.Char (isDigit)
|
||||
import Hledger.Read.RulesReader (parseBalanceAssertionType)
|
||||
import Hledger.Cli.Commands.Print (roundFlag, amountStylesSetRoundingFromRawOpts)
|
||||
@ -87,12 +87,12 @@ close CliOpts{rawopts_=rawopts, reportspec_=rspec0} j = do
|
||||
| mode_ == Retain -> "retain:" <> tagval
|
||||
| otherwise -> "clopen:" <> if null tagval then inferredval else tagval
|
||||
where
|
||||
inferredval = newfilename
|
||||
inferredval = newfilebasename
|
||||
where
|
||||
oldfilename = takeFileName $ journalFilePath j
|
||||
(nonnum, rest) = break isDigit $ reverse oldfilename
|
||||
oldfilebasename = takeBaseName $ journalFilePath j
|
||||
(nonnum, rest) = break isDigit $ reverse oldfilebasename
|
||||
(oldnum, rest2) = span isDigit rest
|
||||
newfilename = case oldnum of
|
||||
newfilebasename = case oldnum of
|
||||
[] -> ""
|
||||
_ -> reverse rest2 <> newnum <> reverse nonnum
|
||||
where
|
||||
|
||||
@ -72,8 +72,8 @@ When migrating to a new file, you'll usually want to bring along the AL or ALE a
|
||||
but not the RX accounts (Revenue, Expense).
|
||||
|
||||
The generated transactions will have a `clopen:` tag.
|
||||
If the main journal's file name contains a number (eg a year number),
|
||||
the tag's value will be that file name with the number incremented.
|
||||
If the main journal's base file name contains a number (eg a year number),
|
||||
the tag's value will be that base file name with the number incremented.
|
||||
Or you can choose the tag value yourself, by using `--clopen=TAGVAL`.
|
||||
|
||||
### close --close
|
||||
|
||||
Loading…
Reference in New Issue
Block a user