diff --git a/hledger/Hledger/Cli/Commands/Close.hs b/hledger/Hledger/Cli/Commands/Close.hs index 206e59dce..4031f79d4 100644 --- a/hledger/Hledger/Cli/Commands/Close.hs +++ b/hledger/Hledger/Cli/Commands/Close.hs @@ -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 diff --git a/hledger/Hledger/Cli/Commands/Close.md b/hledger/Hledger/Cli/Commands/Close.md index f1ba8ade1..2d70fae0f 100644 --- a/hledger/Hledger/Cli/Commands/Close.md +++ b/hledger/Hledger/Cli/Commands/Close.md @@ -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