;run: use leading -- to decide whether to read from files or not
This commit is contained in:
parent
4dbeac284c
commit
7fdb2f7fe6
@ -33,8 +33,6 @@ import Control.Monad.IO.Class (liftIO)
|
||||
import Control.Monad.Extra (concatMapM)
|
||||
|
||||
import System.Exit (ExitCode)
|
||||
import System.Console.CmdArgs.Explicit (expandArgsAt)
|
||||
import System.Directory (doesFileExist)
|
||||
import System.IO (stdin, hIsTerminalDevice, hIsOpen)
|
||||
import System.IO.Unsafe (unsafePerformIO)
|
||||
import System.Console.Haskeline
|
||||
@ -89,15 +87,11 @@ run defaultJournalOverride findBuiltinCommand cliopts@CliOpts{rawopts_=rawopts}
|
||||
then error' "'run' can't read commands from stdin, as one of the input files was stdin as well"
|
||||
else runREPL key findBuiltinCommand
|
||||
else do
|
||||
-- Check if arguments could be interpreted as files.
|
||||
-- If not, assume that they are commands specified directly on the command line
|
||||
allAreFiles <- and <$> mapM (doesFileExist . snd . splitReaderPrefix) args
|
||||
case allAreFiles of
|
||||
True -> runFromFiles key findBuiltinCommand args
|
||||
False ->
|
||||
case args of
|
||||
"--":_ -> runFromArgs key findBuiltinCommand args
|
||||
_ -> error' $ "'run' expects '--' before first command, found none"
|
||||
-- Check if arguments start with "--".
|
||||
-- If not, assume that they are files with commands
|
||||
case args of
|
||||
"--":_ -> runFromArgs key findBuiltinCommand args
|
||||
_ -> runFromFiles key findBuiltinCommand args
|
||||
|
||||
-- | The actual repl command.
|
||||
repl :: (String -> Maybe (Mode RawOpts, CliOpts -> Journal -> IO ())) -> CliOpts -> IO ()
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
2017-01-01 groceries
|
||||
assets:cash -$100
|
||||
expenses:food
|
||||
$ hledger run -f- register cash
|
||||
>2 /hledger: Error: 'run' expects '--' before first command, found none/
|
||||
$ hledger run -f- aregister cash
|
||||
>2 /hledger: aregister: openFile: does not exist \(No such file or directory\)/
|
||||
>=1
|
||||
|
||||
# ** 0. Run refuses to read input file and commands from stdin
|
||||
|
||||
Loading…
Reference in New Issue
Block a user