add isHelp function
[hdata.git] / hdata.hs
blobce2c397edb141d6bdef45660b79d893018f09393
1 module Main where
3 import System.Environment
4 import Add
5 import Bookmark
6 import Citation
7 import Modify
8 import Remove
9 import Search
10 import Util
11 import View
13 help :: [String] -> IO ()
14 help argv = putStrLn $ usage Help
16 usageHelp = "usage: " ++ progName ++ " [operation] [id]\n\
17 \operations:\n\
18 \ add <filters> \n\
19 \ bookmark [options] [id]\n\
20 \ citation [options] [id]\n\
21 \ help [operation] \n\
22 \ modify [options] <filters> <id>\n\
23 \ remove [options] <id>\n\
24 \ search [options] [filters] [id]\n\
25 \ view [options] <id>\n\
26 \ version"
28 version :: IO ()
29 version = putStrLn $ progName ++ " " ++ progVersion
31 main :: IO ()
32 main = do
33 argv <- getArgs
34 if null argv
35 then
36 do
37 error $ "No operation specified ('" ++ progName ++ " help' for help)"
38 else
40 let argv' = tail argv
41 case parseArg (head argv) of
42 Right Add -> add argv'
43 Right Bookmark -> bookmark argv'
44 Right Citation -> citation argv'
45 Right Help -> help argv'
46 Right Modify -> modify argv'
47 Right Remove -> remove argv'
48 Right Search -> search argv'
49 Right View -> view argv'
50 Right Version -> version
51 Left msg -> error msg