From: Martin Grabmueller Date: Wed, 16 Aug 2006 09:14:27 +0000 (+0000) Subject: new option -a (append) for hasktags X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=commitdiff_plain;h=994fa2219ea9881c854f237957f1c851c1bcf8a5 new option -a (append) for hasktags --- diff --git a/utils/hasktags/HaskTags.hs b/utils/hasktags/HaskTags.hs index f184033..43bffee 100644 --- a/utils/hasktags/HaskTags.hs +++ b/utils/hasktags/HaskTags.hs @@ -1,5 +1,4 @@ module Main where -import System import Char import List import IO @@ -34,17 +33,20 @@ main = do putStr $ usageInfo usageString options exitWith (ExitFailure 1) else return () - let mode = getMode modes + let mode = getMode (Append `delete` modes) + let openFileMode = if elem Append modes + then AppendMode + else WriteMode filedata <- mapM findthings filenames if mode == BothTags || mode == CTags then do - ctagsfile <- openFile "tags" WriteMode + ctagsfile <- openFile "tags" openFileMode writectagsfile ctagsfile filedata hClose ctagsfile else return () if mode == BothTags || mode == ETags then do - etagsfile <- openFile "TAGS" WriteMode + etagsfile <- openFile "TAGS" openFileMode writeetagsfile etagsfile filedata hClose etagsfile else return () @@ -58,7 +60,7 @@ getMode [x] = x getMode (x:xs) = max x (getMode xs) -data Mode = ETags | CTags | BothTags | Help deriving (Ord, Eq, Show) +data Mode = ETags | CTags | BothTags | Append | Help deriving (Ord, Eq, Show) options :: [OptDescr Mode] options = [ Option "c" ["ctags"] @@ -67,6 +69,8 @@ options = [ Option "c" ["ctags"] (NoArg ETags) "generate ETAGS file (etags)" , Option "b" ["both"] (NoArg BothTags) ("generate both CTAGS and ETAGS") + , Option "a" ["append"] + (NoArg Append) ("append to existing CTAGS and/or ETAGS file(s)") , Option "h" ["help"] (NoArg Help) "This help" ]