run: allow "run" to invoke "run" (fixes #2331)

This commit is contained in:
Dmitry Astapov 2025-02-23 12:42:32 +00:00 committed by Simon Michael
parent 88a4b0abae
commit 5bd9be2189

View File

@ -101,12 +101,14 @@ runCommand findBuiltinCommand cmdline = do
case findBuiltinCommand cmdname of
Nothing -> putStrLn $ unwords (cmdname:args)
Just (cmdmode,cmdaction) -> do
-- Allow "run" to call "run"
let cmdaction' = if cmdname == "run" then run findBuiltinCommand else cmdaction
-- Normally expandArgsAt is done by the Cli.hs, but it stops at the first '--', so we need
-- to do it here as well to make sure that each command can use @ARGFILEs
args' <- expandArgsAt args
dbg1IO "runCommand final args" (cmdname,args')
opts <- getHledgerCliOpts' cmdmode args'
withJournalCached opts (cmdaction opts)
withJournalCached opts (cmdaction' opts)
[] -> return ()
runREPL :: (String -> Maybe (Mode RawOpts, CliOpts -> Journal -> IO ())) -> IO ()