allow picking patches from files
This commit is contained in:
		
							parent
							
								
									259ad6101b
								
							
						
					
					
						commit
						b52b106ac5
					
				
							
								
								
									
										5
									
								
								Main.hs
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								Main.hs
									
									
									
									
									
								
							|  | @ -344,7 +344,10 @@ runCmd CmdPatch {..} cfg = do | ||||||
|   withSystemTempDirectory "werge-patch" $ \workdir -> do |   withSystemTempDirectory "werge-patch" $ \workdir -> do | ||||||
|     let f = workdir </> "file" |     let f = workdir </> "file" | ||||||
|     bracketFile patchMy ReadMode $ \h -> hSplitToFile cfg h f |     bracketFile patchMy ReadMode $ \h -> hSplitToFile cfg h f | ||||||
|     _ <- runPatch f stdin |     _ <- | ||||||
|  |       case patchInput of | ||||||
|  |         Nothing -> runPatch f stdin | ||||||
|  |         Just path -> bracketFile path ReadMode $ runPatch f | ||||||
|     conflicted <- pmerge f >>= format cfg stdout -- TODO try to resolve more? |     conflicted <- pmerge f >>= format cfg stdout -- TODO try to resolve more? | ||||||
|     if conflicted |     if conflicted | ||||||
|       then exitWith (ExitFailure 1) |       then exitWith (ExitFailure 1) | ||||||
|  |  | ||||||
							
								
								
									
										9
									
								
								Opts.hs
									
									
									
									
									
								
							
							
						
						
									
										9
									
								
								Opts.hs
									
									
									
									
									
								
							|  | @ -230,6 +230,7 @@ data Command | ||||||
|       } |       } | ||||||
|   | CmdPatch |   | CmdPatch | ||||||
|       { patchMy :: FilePath |       { patchMy :: FilePath | ||||||
|  |       , patchInput :: Maybe FilePath | ||||||
|       } |       } | ||||||
|   | CmdBreak |   | CmdBreak | ||||||
|   | CmdGlue |   | CmdGlue | ||||||
|  | @ -295,6 +296,12 @@ cmdDiff = do | ||||||
| cmdPatch :: Parser Command | cmdPatch :: Parser Command | ||||||
| cmdPatch = do | cmdPatch = do | ||||||
|   patchMy <- strArgument $ metavar "MYFILE" <> help "File to be modified" |   patchMy <- strArgument $ metavar "MYFILE" <> help "File to be modified" | ||||||
|  |   patchInput <- | ||||||
|  |     optional . strOption | ||||||
|  |       $ long "patch" | ||||||
|  |           <> short 'p' | ||||||
|  |           <> metavar "PATCH" | ||||||
|  |           <> help "File with the patch (default: stdin)" | ||||||
|   pure CmdPatch {..} |   pure CmdPatch {..} | ||||||
| 
 | 
 | ||||||
| -- TODO have some option to output the (partially merged) my/old/your files so | -- TODO have some option to output the (partially merged) my/old/your files so | ||||||
|  | @ -314,7 +321,7 @@ cmd = | ||||||
|             $ progDesc "Find differences between two files" |             $ progDesc "Find differences between two files" | ||||||
|         , command "patch" |         , command "patch" | ||||||
|             $ info cmdPatch |             $ info cmdPatch | ||||||
|             $ progDesc "Apply a patch from `diff' to file" |             $ progDesc "Modify a file using a patch from `diff'" | ||||||
|         , command "break" |         , command "break" | ||||||
|             $ info (pure CmdBreak) |             $ info (pure CmdBreak) | ||||||
|             $ progDesc "Break text to tokens" |             $ progDesc "Break text to tokens" | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Mirek Kratochvil
						Mirek Kratochvil