support colors
This commit is contained in:
		
							parent
							
								
									b477750ba3
								
							
						
					
					
						commit
						9dfe7b924d
					
				
							
								
								
									
										55
									
								
								Opts.hs
									
									
									
									
									
								
							
							
						
						
									
										55
									
								
								Opts.hs
									
									
									
									
									
								
							|  | @ -3,7 +3,9 @@ | ||||||
| 
 | 
 | ||||||
| module Opts where | module Opts where | ||||||
| 
 | 
 | ||||||
|  | import Data.Bool | ||||||
| import Data.List | import Data.List | ||||||
|  | import Data.Maybe | ||||||
| import Data.Version (showVersion) | import Data.Version (showVersion) | ||||||
| import Options.Applicative | import Options.Applicative | ||||||
| import Paths_werge (version) | import Paths_werge (version) | ||||||
|  | @ -100,33 +102,31 @@ config = do | ||||||
|                    "try to zealously minify conflicts, potentially resolving them" |                    "try to zealously minify conflicts, potentially resolving them" | ||||||
|       , pure False |       , pure False | ||||||
|       ] |       ] | ||||||
|   cfgLabelStart <- |   color <- | ||||||
|     strOption |     flag False True | ||||||
|  |       $ long "color" | ||||||
|  |           <> short 'G' | ||||||
|  |           <> help | ||||||
|  |                "use shorter, gaily colored output markers by default (requires ANSI color support; good for terminals or `less -R')" | ||||||
|  |   labelStart <- | ||||||
|  |     optional . strOption | ||||||
|       $ long "label-start" |       $ long "label-start" | ||||||
|           <> metavar "STRING" |           <> metavar "\"<<<<<\"" | ||||||
|           <> value "<<<<<" |  | ||||||
|           <> showDefault |  | ||||||
|           <> help "label for beginning of the conflict" |           <> help "label for beginning of the conflict" | ||||||
|   cfgLabelMyOld <- |   labelMyOld <- | ||||||
|     strOption |     optional . strOption | ||||||
|       $ long "label-mo" |       $ long "label-mo" | ||||||
|           <> metavar "STRING" |           <> metavar "\"|||||\"" | ||||||
|           <> value "|||||" |  | ||||||
|           <> showDefault |  | ||||||
|           <> help "separator of local edits and original" |           <> help "separator of local edits and original" | ||||||
|   cfgLabelOldYour <- |   labelOldYour <- | ||||||
|     strOption |     optional . strOption | ||||||
|       $ long "label-oy" |       $ long "label-oy" | ||||||
|           <> metavar "STRING" |           <> metavar "\"=====\"" | ||||||
|           <> value "=====" |  | ||||||
|           <> showDefault |  | ||||||
|           <> help "separator of original and other people's edits" |           <> help "separator of original and other people's edits" | ||||||
|   cfgLabelEnd <- |   labelEnd <- | ||||||
|     strOption |     optional . strOption | ||||||
|       $ long "label-end" |       $ long "label-end" | ||||||
|           <> metavar "STRING" |           <> metavar "\">>>>>\"" | ||||||
|           <> value ">>>>>" |  | ||||||
|           <> showDefault |  | ||||||
|           <> help "label for end of the conflict" |           <> help "label for end of the conflict" | ||||||
|   cfgResolveOverlaps <- |   cfgResolveOverlaps <- | ||||||
|     fmap not . switch |     fmap not . switch | ||||||
|  | @ -135,7 +135,18 @@ config = do | ||||||
|     fmap not . switch |     fmap not . switch | ||||||
|       $ long "conflict-separate" |       $ long "conflict-separate" | ||||||
|           <> help "do not resolve separate (non-overlapping) changes" |           <> help "do not resolve separate (non-overlapping) changes" | ||||||
|   pure Config {..} |   pure | ||||||
|  |     Config | ||||||
|  |       { cfgLabelStart = | ||||||
|  |           bool "<<<<<" "\ESC[1;37m<\ESC[0;31m" color `fromMaybe` labelStart | ||||||
|  |       , cfgLabelMyOld = | ||||||
|  |           bool "|||||" "\ESC[1;37m|\ESC[1;30m" color `fromMaybe` labelMyOld | ||||||
|  |       , cfgLabelOldYour = | ||||||
|  |           bool "=====" "\ESC[1;37m=\ESC[0;32m" color `fromMaybe` labelOldYour | ||||||
|  |       , cfgLabelEnd = | ||||||
|  |           bool ">>>>>" "\ESC[1;37m>\ESC[0m" color `fromMaybe` labelEnd | ||||||
|  |       , .. | ||||||
|  |       } | ||||||
| 
 | 
 | ||||||
| data Command | data Command | ||||||
|   = CmdDiff3 |   = CmdDiff3 | ||||||
|  | @ -196,7 +207,7 @@ cmd = | ||||||
| 
 | 
 | ||||||
| parseOpts :: IO (Config, Command) | parseOpts :: IO (Config, Command) | ||||||
| parseOpts = | parseOpts = | ||||||
|   customExecParser (prefs subparserInline) |   customExecParser (prefs helpShowGlobals) | ||||||
|     $ info |     $ info | ||||||
|         (liftA2 (,) config cmd |         (liftA2 (,) config cmd | ||||||
|            <**> helper |            <**> helper | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Mirek Kratochvil
						Mirek Kratochvil