-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMain.hs
24 lines (18 loc) · 904 Bytes
/
Main.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
module Main where
-- import Control.Monad ( (<<) )
import System( getArgs )
import System.IO( stderr, hPutStrLn )
import System.Process( runCommand, waitForProcess)
import Data.List( nub, sort, isPrefixOf )
main = do args <- getArgs
if (length args >= 2) then
do let file = head args
let current_word = (head . tail) args
procHandle <- runCommand $ command file
exitcode <- waitForProcess procHandle
text <- readFile "/tmp/textmatetags"
mapM_ (putStrLn) $ sort . nub . filter (isPrefixOf current_word)
$ map (head . words) (lines text)
else
hPutStrLn stderr "Provide a haskell file and a current word!"
where command file = "echo \":ctags /tmp/textmatetags\" | ghci " ++ file ++" &> /tmp/runtags"