codex 0.2.0.3 → 0.2.1.0
raw patch · 8 files changed
+88/−54 lines, 8 filesdep ~MissingHdep ~codexdep ~textPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: MissingH, codex, text
API changes (from Hackage documentation)
+ Codex: HasktagsEmacs :: Tagger
+ Codex: defaultTagsFileName :: FilePath
+ Codex: tagsFileName :: Codex -> FilePath
+ Codex.Internal: defaultTagsFileName :: FilePath
+ Codex.Internal: tagsFileName :: Codex -> FilePath
- Codex: Codex :: Bool -> FilePath -> String -> Bool -> Bool -> Codex
+ Codex: Codex :: Bool -> FilePath -> String -> Bool -> Bool -> FilePath -> Codex
- Codex: isUpdateRequired :: Codex -> FilePath -> [PackageIdentifier] -> String -> Action Bool
+ Codex: isUpdateRequired :: Codex -> [PackageIdentifier] -> String -> Action Bool
- Codex.Internal: Codex :: Bool -> FilePath -> String -> Bool -> Bool -> Codex
+ Codex.Internal: Codex :: Bool -> FilePath -> String -> Bool -> Bool -> FilePath -> Codex
Files
- codex.cabal +9/−7
- codex/Main.hs +5/−7
- codex/Main/Config.hs +28/−32
- codex/Main/Config/Codex0.hs +7/−0
- codex/Main/Config/Codex1.hs +7/−3
- codex/Main/Config/Codex2.hs +20/−0
- src/Codex.hs +7/−4
- src/Codex/Internal.hs +5/−1
codex.cabal view
@@ -1,13 +1,14 @@ name: codex-version: 0.2.0.3+version: 0.2.1.0 synopsis: A ctags file generator for cabal project dependencies. description: This tool download and cache the source code of packages in your local hackage, it can then use this cache to generate `tags` files aggregating the sources of all the dependencies of your cabal projects.- . - You basically do `codex update` in your cabal project directory and you'll get a `codex.tags` file- that you can use in your favorite text editor. .+ You basically do `codex update` in your cabal project directory and you'll get a file+ (`codex.tags` by default, or `TAGS` when using emacs format) that you can use in your+ favorite text editor.+ . Usage overview can be found in the <http://github.com/aloiscochard/codex#codex README>. homepage: http://github.com/aloiscochard/codex@@ -39,10 +40,10 @@ , hackage-db >= 1.8 && < 1.9 , machines >= 0.2 && < 0.3 , machines-directory >= 0.0.0.2 && < 0.1- , MissingH >= 1.2.1.0 && < 1.3+ , MissingH >= 1.2.1.0 && < 1.4 , process >= 1.1.0.2 && < 1.3 , tar >= 0.4.0.1 && < 0.5- , text >= 1.1.1.3 && < 1.2+ , text >= 1.1.1.3 && < 1.3 , transformers >= 0.3.0.0 && < 0.5 , zlib >= 0.5.4.1 && < 0.6 @@ -55,6 +56,7 @@ Main.Config Main.Config.Codex0 Main.Config.Codex1+ Main.Config.Codex2 build-depends: base , Cabal@@ -66,7 +68,7 @@ , MissingH , monad-loops >= 0.4.2 && < 0.5 , yaml >= 0.8.8.3 && < 0.9- , codex == 0.2.0.3+ , codex == 0.2.1.0 -- Have to fix it otherwise `Backjump limit reached` , transformers == 0.3.0.0 -- Have to bound it otherwise fail compile with version 0.4
codex/Main.hs view
@@ -29,9 +29,6 @@ Left ls -> fmap (left (++ ls)) x Right r -> return $ Right r -tagsFile :: FilePath-tagsFile = joinPath ["codex.tags"]- hashFile :: Codex -> FilePath hashFile cx = hackagePath cx </> "codex.hash" @@ -65,7 +62,7 @@ shouldUpdate <- if (null workspaceProjects') then- either (const True) id <$> (runEitherT $ isUpdateRequired cx tagsFile dependencies projectHash)+ either (const True) id <$> (runEitherT $ isUpdateRequired cx dependencies projectHash) else return True if (shouldUpdate || force) then do@@ -81,6 +78,7 @@ else putStrLn "Nothing to update." where+ tagsFile = tagsFileName cx getTags i = status cx i >>= \x -> case x of (Source Tagged) -> return () (Source Untagged) -> tags cx i >>= (const $ getTags i)@@ -93,8 +91,8 @@ , " [--help]" , " [--version]" , ""- , " update Synchronize the `codex.tags` file in the current cabal project directory"- , " update --force Discard `codex.tags` file hash and force regeneration"+ , " update Synchronize the tags file in the current cabal project directory"+ , " update --force Discard tags file hash and force regeneration" , " cache clean Remove all `tags` file from the local hackage cache]" , " set tagger <tagger> Update the `~/.codex` configuration file for the given tagger (hasktags|ctags)." , " set format <format> Update the `~/.codex` configuration file for the given format (vim|emacs|sublime)."@@ -113,7 +111,7 @@ run cx ["update", "--force"] = withConfig cx (\x -> update x True) run cx ["set", "tagger", "ctags"] = encodeConfig $ cx { tagsCmd = taggerCmd Ctags } run cx ["set", "tagger", "hasktags"] = encodeConfig $ cx { tagsCmd = taggerCmd Hasktags }- run cx ["set", "format", "emacs"] = encodeConfig $ cx { tagsFileHeader = False, tagsFileSorted = False }+ run cx ["set", "format", "emacs"] = encodeConfig $ cx { tagsCmd = taggerCmd HasktagsEmacs, tagsFileHeader = False, tagsFileSorted = False, tagsFileName = "TAGS" } run cx ["set", "format", "sublime"] = encodeConfig $ cx { tagsCmd = taggerCmd HasktagsExtended, tagsFileHeader = True, tagsFileSorted = True } run cx ["set", "format", "vim"] = encodeConfig $ cx { tagsFileHeader = True, tagsFileSorted = True } run cx ["--version"] = putStrLn $ concat ["codex: ", display version]
codex/Main/Config.hs view
@@ -2,19 +2,17 @@ {-# LANGUAGE StandaloneDeriving #-} module Main.Config where -import Data.Hash.MD5 import Data.Yaml import GHC.Generics import System.Directory import System.FilePath -import qualified Data.ByteString.Char8 as BS- import Codex import qualified Main.Config.Codex0 as C0 import qualified Main.Config.Codex1 as C1+import qualified Main.Config.Codex2 as C2 import qualified Distribution.Hackage.DB as DB data ConfigState = Ready | TaggerNotFound@@ -41,7 +39,7 @@ loadConfig = decodeConfig >>= maybe defaultConfig return where defaultConfig = do hp <- DB.hackagePath- let cx = Codex True (dropFileName hp) (taggerCmd Hasktags) True True+ let cx = Codex True (dropFileName hp) (taggerCmd Hasktags) True True defaultTagsFileName encodeConfig cx return cx @@ -56,40 +54,38 @@ cfg <- config path case cfg of Nothing -> do- cfg1 <- config1 path- case cfg1 of- Nothing -> do- cfg0 <- config0 path- case cfg0 of- Nothing -> return Nothing- Just cfg0 -> do- encodeConfig cfg- warn- return $ Just cfg- where- cfg = migrate cfg0- migrate cx = Codex True (C0.hackagePath cx) (C0.tagsCmd cx) True True- Just cfg1 -> do- encodeConfig cfg- warn- return $ Just cfg- where- cfg = migrate cfg1- migrate cx = Codex True (C1.hackagePath cx) (C1.tagsCmd cx) (C1.tagsFileHeader cx) (C1.tagsFileSorted cx)+ cfg2 <- config2 path+ case cfg2 of+ Nothing -> do+ cfg1 <- config1 path+ case cfg1 of+ Nothing -> config0 path+ cfg1 -> return cfg1+ cfg2 -> return cfg2 cfg -> return cfg where- warn = do+ warn migrateWarn = do putStrLn "codex: *warning* your configuration has been migrated automatically!\n"- C1.warn+ migrateWarn putStrLn ""- config :: FilePath -> IO (Maybe Codex)- config = configOf- config0 :: FilePath -> IO (Maybe C0.Codex)- config0 = configOf- config1 :: FilePath -> IO (Maybe C1.Codex)- config1 = configOf+ config = configOf+ config0 = reencodeConfigOf C0.migrate C0.migrateWarn+ config1 = reencodeConfigOf C1.migrate C1.migrateWarn+ config2 = reencodeConfigOf C2.migrate C2.migrateWarn++ reencodeConfigOf migrate migrateWarn path = do+ rawCfg <- configOf path+ let cfg = fmap migrate rawCfg+ case cfg of+ Nothing -> return ()+ Just cfg -> do+ encodeConfig cfg+ warn migrateWarn+ return cfg+ configOf path = do res <- decodeFileEither path return $ eitherToMaybe res+ eitherToMaybe x = either (const Nothing) Just x
codex/Main/Config/Codex0.hs view
@@ -4,9 +4,16 @@ import Data.Yaml import GHC.Generics +import qualified Codex as New+ data Codex = Codex { hackagePath :: FilePath, tagsCmd :: String } deriving Generic instance ToJSON Codex instance FromJSON Codex +migrateWarn :: IO ()+migrateWarn = return ()++migrate :: Codex -> New.Codex+migrate cx = New.Codex True (hackagePath cx) (tagsCmd cx) True True New.defaultTagsFileName
codex/Main/Config/Codex1.hs view
@@ -4,14 +4,18 @@ import Data.Yaml import GHC.Generics +import qualified Codex as New+ data Codex = Codex { hackagePath :: FilePath, tagsCmd :: String, tagsFileHeader :: Bool, tagsFileSorted :: Bool } deriving Generic instance ToJSON Codex instance FromJSON Codex -warn :: IO ()-warn = do- putStrLn "\tThe `codex.tags` will now include the tags of the *current* project as well,"+migrateWarn :: IO ()+migrateWarn = do+ putStrLn "\tThe tags file will now include the tags of the *current* project as well," putStrLn "\tif that is not the behavior you want, please edit `~/.codex`." +migrate :: Codex -> New.Codex+migrate cx = New.Codex True (hackagePath cx) (tagsCmd cx) (tagsFileHeader cx) (tagsFileSorted cx) New.defaultTagsFileName
+ codex/Main/Config/Codex2.hs view
@@ -0,0 +1,20 @@+{-# LANGUAGE DeriveGeneric #-}+module Main.Config.Codex2 where++import Data.Yaml+import GHC.Generics++import qualified Codex as New++data Codex = Codex { currentProjectIncluded :: Bool, hackagePath :: FilePath, tagsCmd :: String, tagsFileHeader :: Bool, tagsFileSorted :: Bool }+ deriving Generic++instance ToJSON Codex+instance FromJSON Codex++migrateWarn :: IO ()+migrateWarn = return ()++migrate :: Codex -> New.Codex+migrate cx =+ New.Codex True (hackagePath cx) (tagsCmd cx) (tagsFileHeader cx) (tagsFileSorted cx) New.defaultTagsFileName
src/Codex.hs view
@@ -1,4 +1,4 @@-module Codex (Codex(..), Verbosity, module Codex) where+module Codex (Codex(..), defaultTagsFileName, Verbosity, module Codex) where import Control.Exception (try, SomeException) import Control.Monad@@ -44,12 +44,13 @@ type Action = EitherT String IO -data Tagger = Ctags | Hasktags | HasktagsExtended+data Tagger = Ctags | Hasktags | HasktagsEmacs | HasktagsExtended deriving (Eq, Show, Read) taggerCmd :: Tagger -> String taggerCmd Ctags = "ctags --tag-relative=no --recurse -f '$TAGS' '$SOURCES'" taggerCmd Hasktags = "hasktags --ctags --output='$TAGS' '$SOURCES'"+taggerCmd HasktagsEmacs = "hasktags --etags --output='$TAGS' '$SOURCES'" taggerCmd HasktagsExtended = "hasktags --ctags --extendedctag --output='$TAGS' '$SOURCES'" taggerCmdRun :: Codex -> FilePath -> FilePath -> Action FilePath@@ -82,8 +83,8 @@ p fp = any (\f -> f fp) (fmap List.isSuffixOf extensions) extensions = [".hs", ".lhs", ".hsc"] -isUpdateRequired :: Codex -> FilePath -> [PackageIdentifier] -> String -> Action Bool-isUpdateRequired cx file ds ph = do+isUpdateRequired :: Codex -> [PackageIdentifier] -> String -> Action Bool+isUpdateRequired cx ds ph = do fileExist <- tryIO $ doesFileExist file if fileExist then do content <- tryIO $ TLIO.readFile file@@ -91,6 +92,8 @@ return $ hash /= (Text.pack $ tagsFileHash cx ds ph) else return True+ where+ file = tagsFileName cx status :: Codex -> PackageIdentifier -> Action Status status cx i = do
src/Codex/Internal.hs view
@@ -6,12 +6,16 @@ import Distribution.Verbosity import System.FilePath +defaultTagsFileName :: FilePath+defaultTagsFileName = "codex.tags"+ data Codex = Codex { currentProjectIncluded :: Bool , hackagePath :: FilePath , tagsCmd :: String , tagsFileHeader :: Bool- , tagsFileSorted :: Bool }+ , tagsFileSorted :: Bool+ , tagsFileName :: FilePath } deriving Show packagePath :: Codex -> PackageIdentifier -> FilePath