Let annotator work in batch mode
This commit is contained in:
parent
9da29e683a
commit
3c43cd7c5d
1 changed files with 15 additions and 9 deletions
|
|
@ -50,6 +50,7 @@ data Options = Options
|
|||
, verbosity :: Verbosity
|
||||
, showVersion :: Maybe ShowVersion
|
||||
, showHelp :: Bool
|
||||
, batchMode :: Bool
|
||||
, contextLines :: Int
|
||||
, onlyNewest :: Bool
|
||||
, annotationFiles :: [FilePath]
|
||||
|
|
@ -64,6 +65,7 @@ defaultOptions = Options
|
|||
, verbosity = Silent
|
||||
, showVersion = Nothing
|
||||
, showHelp = False
|
||||
, batchMode = False
|
||||
, contextLines = 0
|
||||
, onlyNewest = True
|
||||
, annotationFiles = []
|
||||
|
|
@ -88,6 +90,9 @@ options =
|
|||
, Option ['h'] ["help"]
|
||||
(NoArg (\opts -> opts { showHelp = True }))
|
||||
"show usage information"
|
||||
, Option ['b'] ["batch"]
|
||||
(NoArg (\opts -> opts { batchMode = True }))
|
||||
"run in batch mode, i.e. do not ask any questions"
|
||||
, Option ['a'] ["all"]
|
||||
(NoArg (\opts -> opts { onlyNewest = False}))
|
||||
"handle all defects not just Newest"
|
||||
|
|
@ -152,7 +157,7 @@ defaultMain = do
|
|||
putStr $ usageInfo header options
|
||||
exitWith ExitSuccess
|
||||
|
||||
automaticAnnotations <- rights . concat <$> mapM fromFile (annotationFiles opts)
|
||||
automaticAnnotations <- rights . concat <$> (filterM fileExist (annotationFiles opts) >>= mapM fromFile)
|
||||
|
||||
let opts' = opts { autoAnnotations = automaticAnnotations }
|
||||
|
||||
|
|
@ -384,14 +389,15 @@ handleViolation content v@Violation{..} = do
|
|||
, description
|
||||
])
|
||||
putStrLn (code))
|
||||
|
||||
|
||||
choice <- getUserChoice v
|
||||
case choice of
|
||||
Abort -> liftIO $ exitSuccess
|
||||
Annotate annotation -> pure $ Just (AnnotatedViolation v annotation indent)
|
||||
Skip -> pure Nothing
|
||||
Help -> handleViolation content v
|
||||
if batchMode opts
|
||||
then pure $ Nothing
|
||||
else do
|
||||
choice <- getUserChoice v
|
||||
case choice of
|
||||
Abort -> liftIO $ exitSuccess
|
||||
Annotate annotation -> pure $ Just (AnnotatedViolation v annotation indent)
|
||||
Skip -> pure Nothing
|
||||
Help -> handleViolation content v
|
||||
where
|
||||
lookupAnnotation :: Rule -> [Annotation] -> Maybe Annotation
|
||||
lookupAnnotation _ [] = Nothing
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue