Add a license
[hdata.git] / hdata.hs
blob46b86e3534503b90d6c53f89f8bdf45d02da3ec4
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
23 import Add
24 import Bookmark
25 import Citation
26 import Modify
27 import Remove
28 import Search
29 import Util
30 import View
32 help :: [String] -> IO ()
33 help argv = putStrLn $ usageHelp
35 usageHelp = "usage: " ++ progName ++ " [operation] [id]\n\
36 \operations:\n\
37 \ add <filters> \n\
38 \ bookmark [options] [id]\n\
39 \ citation [options] [id]\n\
40 \ help [operation] \n\
41 \ modify [options] <filters> <id>\n\
42 \ remove [options] <id>\n\
43 \ search [options] [filters] [id]\n\
44 \ view [options] <id>\n\
45 \ version"
47 version :: IO ()
48 version = do
49 putStrLn $ progName ++ " v" ++ progVersion
50 putStrLn "© 2013 Louis-Guillaume Gagnon - GPLv3+"
53 main :: IO ()
54 main = do
55 argv <- getArgs
56 if null argv
57 then
58 do
59 error $ "No operation specified ('" ++ progName ++ " help' for help)"
60 else
62 let argv' = tail argv
63 case parseArg (head argv) of
64 Right Add -> add argv'
65 Right Bookmark -> bookmark argv'
66 Right Citation -> citation argv'
67 Right Help -> help argv'
68 Right Modify -> modify argv'
69 Right Remove -> remove argv'
70 Right Search -> search argv'
71 Right View -> view argv'
72 Right Version -> version
73 Left msg -> error msg