Add.hs: use usageFilters from Tools/Filter.hs
[hdata.git] / src / hdata.hs
blob08bfc62553cab375be10170a612f753a1149d1c7
1 {-
2 hdata.hs
4 Copyright 2013 Louis-Guillaume Gagnon <louis.guillaume.gagnon@gmail.com>
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 module Main where
22 import System.Environment
24 import Add
25 import Bookmark
26 import Citation
27 import Modify
28 import Remove
29 import Search
30 import Tools.Constants
31 import Tools.Operation
32 import View
34 help :: [String] -> IO ()
35 help argv = putStrLn $ usageHelp
37 usageHelp = "usage: " ++ progName ++ " [operation] [id]\n\
38 \operations:\n\
39 \ add <filters> \n\
40 \ bookmark [options] [id]\n\
41 \ citation [options] [id]\n\
42 \ help [operation] \n\
43 \ modify [options] <filters> <id>\n\
44 \ remove [options] <id>\n\
45 \ search [options] [filters] [id]\n\
46 \ view [options] <id>\n\
47 \ version"
49 version :: IO ()
50 version = do
51 putStrLn $ progName ++ " v" ++ progVersion
52 putStrLn "© 2013 Louis-Guillaume Gagnon - GPLv3+"
55 main :: IO ()
56 main = do
57 argv <- getArgs
58 if null argv
59 then
60 do
61 error $ "No operation specified ('" ++ progName ++ " help' for help)"
62 else
64 let argv' = tail argv
65 case parseArg (head argv) of
66 Right Add -> add argv'
67 Right Bookmark -> bookmark argv'
68 Right Citation -> citation argv'
69 Right Help -> help argv'
70 Right Modify -> modify argv'
71 Right Remove -> remove argv'
72 Right Search -> search argv'
73 Right View -> view argv'
74 Right Version -> version
75 Left msg -> error msg