Skip to content

Commit

Permalink
Merge pull request #16 from afcowie/output-option
Browse files Browse the repository at this point in the history
Output option
  • Loading branch information
luqui committed Jun 3, 2014
2 parents ecbcb1d + 93ccbf8 commit e8b354e
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1 +1,2 @@
dist dist
tags
19 changes: 16 additions & 3 deletions Main.hs
Expand Up @@ -5,7 +5,7 @@ module Main where


import qualified Language.Haskell.Exts.Annotated as L import qualified Language.Haskell.Exts.Annotated as L
import System.Console.CmdArgs import System.Console.CmdArgs
import System.IO (hPutStrLn, stderr) import System.IO (hPutStrLn, stderr, stdout, IOMode(..), openFile, hClose)
import qualified Data.Map as Map import qualified Data.Map as Map
import qualified Language.Preprocessor.Cpphs as CPP import qualified Language.Preprocessor.Cpphs as CPP
import Control.Monad (forM) import Control.Monad (forM)
Expand Down Expand Up @@ -233,7 +233,7 @@ moduleFile (L.Module (L.SrcSpanInfo (L.SrcSpan file _ _ _ _) _) _ _ _ _) = file
moduleFile _ = error "Wtf is an XmlPage/XmlHybrid?" moduleFile _ = error "Wtf is an XmlPage/XmlHybrid?"


data HotHasktags = HotHasktags { data HotHasktags = HotHasktags {
hh_files, hh_language, hh_define, hh_include, hh_cpphs :: [String] } hh_files, hh_language, hh_define, hh_include, hh_output, hh_cpphs :: [String] }
deriving (Data,Typeable,Show) deriving (Data,Typeable,Show)


defaultHotHasktags :: HotHasktags defaultHotHasktags :: HotHasktags
Expand All @@ -257,6 +257,11 @@ defaultHotHasktags = HotHasktags {
\paths are currently interpreted as relative to the directory \ \paths are currently interpreted as relative to the directory \
\containing the source file \ \containing the source file \
\-Ifoo is a shortcut for -c -Ifoo", \-Ifoo is a shortcut for -c -Ifoo",
hh_output = []
&= name "output" &= name "O"
&= explicit
&= typ "FILE"
&= help "Name of output file. Default is to write to stdout",
hh_cpphs = [] hh_cpphs = []
&= name "cpp" &= name "c" &= name "cpp" &= name "c"
&= explicit &= explicit
Expand All @@ -275,4 +280,12 @@ main = do
++ unknown ++ unknown
database <- makeDatabase exts conf database <- makeDatabase exts conf
let tags = sort $ concatMap (\mod -> makeTags (moduleFile mod) (moduleScope database mod)) (Map.elems database) let tags = sort $ concatMap (\mod -> makeTags (moduleFile mod) (moduleScope database mod)) (Map.elems database)
mapM_ putStrLn tags handle <- case (hh_output conf) of
[] -> return stdout
file:_ -> openFile file WriteMode

mapM_ (hPutStrLn handle) tags

case (hh_output conf) of
[] -> return ()
_ -> hClose handle
17 changes: 17 additions & 0 deletions Makefile
@@ -0,0 +1,17 @@
all: build tags
.PHONY: all build install

build: dist/setup-config dist/build/hothasktags/hothasktags

dist/setup-config: hothasktags.cabal
cabal install --only-dependencies
cabal configure

dist/build/hothasktags/hothasktags: Main.hs
cabal build

install:
cabal install

tags: build
dist/build/hothasktags/hothasktags *.hs > tags
2 changes: 1 addition & 1 deletion hothasktags.cabal
Expand Up @@ -38,7 +38,7 @@ executable hothasktags
containers, containers,
filepath, filepath,
haskell-src-exts >= 1.14, haskell-src-exts >= 1.14,
cpphs >= 1.11 && < 1.17, cpphs >= 1.11 && < 1.19,
cmdargs cmdargs
main-is: Main.hs main-is: Main.hs
ghc-options: -W ghc-options: -W

0 comments on commit e8b354e

Please sign in to comment.