web: disallow -f- which doesn't work (fixes #202)
hledger-web -f- gives [Error#yesod-core] <stdin>: hGetContents: illegal operation (handle is closed) and I can't see why. Just disallow it.
This commit is contained in:
		
							parent
							
								
									3fa3926ee9
								
							
						
					
					
						commit
						2c3f1b672e
					
				| @ -52,9 +52,15 @@ runWith opts | |||||||
| 
 | 
 | ||||||
| withJournalDo' :: WebOpts -> (WebOpts -> Journal -> IO ()) -> IO () | withJournalDo' :: WebOpts -> (WebOpts -> Journal -> IO ()) -> IO () | ||||||
| withJournalDo' opts cmd = do | withJournalDo' opts cmd = do | ||||||
|   -- XXX head should be safe for now |   f <- head `fmap` journalFilePathFromOpts (cliopts_ opts) -- XXX head should be safe for now | ||||||
|   (head `fmap` journalFilePathFromOpts (cliopts_ opts)) >>= readJournalFile Nothing Nothing True >>= | 
 | ||||||
|     either error' (cmd opts . journalApplyAliases (aliasesFromOpts $ cliopts_ opts)) |   -- https://github.com/simonmichael/hledger/issues/202 | ||||||
|  |   -- -f- gives [Error#yesod-core] <stdin>: hGetContents: illegal operation (handle is closed) for some reason | ||||||
|  |   -- Also we may be writing to this file. Just disallow it. | ||||||
|  |   when (f == "-") $ error' "hledger-web doesn't support --f -, please specify a file path" | ||||||
|  | 
 | ||||||
|  |   readJournalFile Nothing Nothing True f >>= | ||||||
|  |    either error' (cmd opts . journalApplyAliases (aliasesFromOpts $ cliopts_ opts)) | ||||||
| 
 | 
 | ||||||
| -- | The web command. | -- | The web command. | ||||||
| web :: WebOpts -> Journal -> IO () | web :: WebOpts -> Journal -> IO () | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user