]> gitweb.michael.orlitzky.com - dead/halcyon.git/blob - src/CommandLine.hs
862f9cd9ad92200bd698a41cccbad83f03040230
[dead/halcyon.git] / src / CommandLine.hs
1 module CommandLine (
2 get_args,
3 show_help)
4 where
5
6 import System.Console.CmdArgs (
7 (&=),
8 args,
9 cmdArgs,
10 def,
11 details,
12 groupname,
13 help,
14 helpArg,
15 program,
16 summary,
17 typ,
18 versionArg)
19 import System.Environment (withArgs)
20
21 -- Get the version from Cabal.
22 import Paths_halcyon (version)
23 import Data.Version (showVersion)
24
25 import OptionalConfiguration
26
27 description :: String
28 description =
29 "Monitor a list of Twitter accounts and display or email any new tweets."
30
31 program_name :: String
32 program_name = "halcyon"
33
34 my_summary :: String
35 my_summary = program_name ++ "-" ++ (showVersion version)
36
37 consumer_key_help :: String
38 consumer_key_help = "Your Twitter API consumer key"
39
40 consumer_secret_help :: String
41 consumer_secret_help = "Your Twitter API consumer secret"
42
43 access_token_help :: String
44 access_token_help = "Your Twitter API access token"
45
46 access_secret_help :: String
47 access_secret_help = "Your Twitter API access secret"
48
49 heartbeat_help :: String
50 heartbeat_help = "How many seconds to wait between polling"
51
52 to_address_help :: String
53 to_address_help = "Send tweets to ADDRESS"
54
55 from_address_help :: String
56 from_address_help = "Send tweets from ADDRESS"
57
58 sendmail_path_help :: String
59 sendmail_path_help = "Use PATH to send mail"
60
61 ignore_replies_help :: String
62 ignore_replies_help = "Ignore replies to other tweets"
63
64 ignore_retweets_help :: String
65 ignore_retweets_help = "Ignore retweets from other users"
66
67 verbose_help :: String
68 verbose_help = "Be verbose about stuff"
69
70 arg_spec :: OptionalCfg
71 arg_spec =
72 OptionalCfg {
73 consumer_key =
74 def &= typ "KEY"
75 &= groupname "Twitter API"
76 &= help consumer_key_help,
77
78 consumer_secret =
79 def &= typ "SECRET"
80 &= groupname "Twitter API"
81 &= help consumer_secret_help,
82
83 access_token =
84 def &= typ "TOKEN"
85 &= groupname "Twitter API"
86 &= help access_token_help,
87
88 access_secret =
89 def &= typ "SECRET"
90 &= groupname "Twitter API"
91 &= help access_secret_help,
92
93 heartbeat =
94 def &= groupname "Miscellaneous"
95 &= help heartbeat_help,
96
97 ignore_replies =
98 def &= groupname "Miscellaneous"
99 &= help ignore_replies_help,
100
101 ignore_retweets =
102 def &= groupname "Miscellaneous"
103 &= help ignore_retweets_help,
104
105 verbose =
106 def &= groupname "Miscellaneous"
107 &= help verbose_help,
108
109 sendmail_path =
110 def &= typ "PATH"
111 &= groupname "Mail Options"
112 &= help sendmail_path_help,
113
114 from_address =
115 def &= typ "ADDRESS"
116 &= groupname "Mail Options"
117 &= help from_address_help,
118
119 to_address =
120 def &= typ "ADDRESS"
121 &= groupname "Mail Options"
122 &= help to_address_help,
123
124 usernames =
125 def &= args
126 &= typ "USERNAMES" }
127
128 &= program program_name
129 &= summary my_summary
130 &= details [description]
131 &= helpArg [groupname "Common flags"]
132 &= versionArg [groupname "Common flags"]
133
134 show_help :: IO OptionalCfg
135 show_help = withArgs ["--help"] get_args
136
137
138 get_args :: IO OptionalCfg
139 get_args = cmdArgs arg_spec