;run: require -- before first command (+test for that)

This commit is contained in:
Dmitry Astapov 2025-03-06 20:37:38 +00:00 committed by Simon Michael
parent b031144961
commit 9c63b36d88
2 changed files with 13 additions and 1 deletions

View File

@ -89,7 +89,10 @@ run defaultJournalOverride findBuiltinCommand cliopts@CliOpts{rawopts_=rawopts}
allAreFiles <- and <$> mapM (doesFileExist . snd . splitReaderPrefix) args
case allAreFiles of
True -> runFromFiles key findBuiltinCommand args
False -> runFromArgs key findBuiltinCommand args
False ->
case args of
"--":_ -> runFromArgs key findBuiltinCommand args
_ -> error' $ "'run' expects '--' before first command, found none"
-- | The actual repl command.
repl :: (String -> Maybe (Mode RawOpts, CliOpts -> Journal -> IO ())) -> CliOpts -> IO ()

View File

@ -1,5 +1,14 @@
# * run command
# ** 0. Run requires -- before first command
<
2017-01-01 groceries
assets:cash -$100
expenses:food
$ hledger run -f- register cash
>2 /hledger: Error: 'run' expects '--' before first command, found none/
>=1
# ** 0. Run one command from command line
<
2017-01-01 groceries