Improve display of newlines around error and warning messages.
This commit is contained in:
		
					parent
					
						
							
								14f75ced75
							
						
					
				
			
			
				commit
				
					
						07125dca53
					
				
			
		
					 5 changed files with 23 additions and 7 deletions
				
			
		| 
						 | 
					@ -89,8 +89,8 @@ tryRun' errnum state (a:as) = do
 | 
				
			||||||
	case result of
 | 
						case result of
 | 
				
			||||||
		Left err -> do
 | 
							Left err -> do
 | 
				
			||||||
			Annex.eval state $ do
 | 
								Annex.eval state $ do
 | 
				
			||||||
				showEndFail
 | 
					 | 
				
			||||||
				showErr err
 | 
									showErr err
 | 
				
			||||||
 | 
									showEndFail
 | 
				
			||||||
			tryRun' (errnum + 1) state as
 | 
								tryRun' (errnum + 1) state as
 | 
				
			||||||
		Right (True,state') -> tryRun' errnum state' as
 | 
							Right (True,state') -> tryRun' errnum state' as
 | 
				
			||||||
		Right (False,state') -> tryRun' (errnum + 1) state' as
 | 
							Right (False,state') -> tryRun' (errnum + 1) state' as
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -103,7 +103,6 @@ doCommand = start
 | 
				
			||||||
		stage a b = b >>= a
 | 
							stage a b = b >>= a
 | 
				
			||||||
		success = return True
 | 
							success = return True
 | 
				
			||||||
		failure = do
 | 
							failure = do
 | 
				
			||||||
			showOutput -- avoid clutter around error message
 | 
					 | 
				
			||||||
			showEndFail
 | 
								showEndFail
 | 
				
			||||||
			return False
 | 
								return False
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										11
									
								
								Messages.hs
									
										
									
									
									
								
							
							
						
						
									
										11
									
								
								Messages.hs
									
										
									
									
									
								
							| 
						 | 
					@ -73,16 +73,17 @@ showEndResult b = handle (JSON.end b) $ putStrLn msg
 | 
				
			||||||
			| otherwise = "failed"
 | 
								| otherwise = "failed"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
showErr :: (Show a) => a -> Annex ()
 | 
					showErr :: (Show a) => a -> Annex ()
 | 
				
			||||||
showErr e = liftIO $ do
 | 
					showErr e = warning' $ "git-annex: " ++ show e
 | 
				
			||||||
	hFlush stdout
 | 
					 | 
				
			||||||
	hPutStrLn stderr $ "git-annex: " ++ show e
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
warning :: String -> Annex ()
 | 
					warning :: String -> Annex ()
 | 
				
			||||||
warning w = do
 | 
					warning w = warning' (indent w)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					warning' :: String -> Annex ()
 | 
				
			||||||
 | 
					warning' w = do
 | 
				
			||||||
	handle q $ putStr "\n"
 | 
						handle q $ putStr "\n"
 | 
				
			||||||
	liftIO $ do
 | 
						liftIO $ do
 | 
				
			||||||
		hFlush stdout
 | 
							hFlush stdout
 | 
				
			||||||
		hPutStrLn stderr $ indent w
 | 
							hPutStrLn stderr w
 | 
				
			||||||
 | 
					
 | 
				
			||||||
indent :: String -> String
 | 
					indent :: String -> String
 | 
				
			||||||
indent s = join "\n" $ map (\l -> "  " ++ l) $ lines s
 | 
					indent s = join "\n" $ map (\l -> "  " ++ l) $ lines s
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										6
									
								
								debian/changelog
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								debian/changelog
									
										
									
									
										vendored
									
									
								
							| 
						 | 
					@ -1,3 +1,9 @@
 | 
				
			||||||
 | 
					git-annex (3.20110903) UNRELEASED; urgency=low
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  * Improve display of newlines around error and warning messages.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 -- Joey Hess <joeyh@debian.org>  Tue, 06 Sep 2011 13:45:16 -0400
 | 
				
			||||||
 | 
					
 | 
				
			||||||
git-annex (3.20110902) unstable; urgency=low
 | 
					git-annex (3.20110902) unstable; urgency=low
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  * Set EMAIL when running test suite so that git does not need to be
 | 
					  * Set EMAIL when running test suite so that git does not need to be
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -34,3 +34,13 @@ The newline is in the wrong place and confuses the user. It should be printed _a
 | 
				
			||||||
> failed
 | 
					> failed
 | 
				
			||||||
> 
 | 
					> 
 | 
				
			||||||
> --[[Joey]] 
 | 
					> --[[Joey]] 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					>> Well, I fixed this in all cases except a thrown non-IO error (last
 | 
				
			||||||
 | 
					>> example aboce), which output is printed by haskell's runtime. I'd
 | 
				
			||||||
 | 
					>> have to add a second error handler to handle those, and it's not
 | 
				
			||||||
 | 
					>> clear what it would do. Often an error will occur before anything
 | 
				
			||||||
 | 
					>> else is printed, and then the current behavior is right; if something
 | 
				
			||||||
 | 
					>> has been printed it would be nice to have a newline before the error,
 | 
				
			||||||
 | 
					>> but by the time the error is caught we'd be out of the annex monad
 | 
				
			||||||
 | 
					>> and not really have any way to know if something has been printed.
 | 
				
			||||||
 | 
					>> I think my fix is good enough [[done]] --[[Joey]] 
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue