Clean up a bunch of code and comments.
[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 ( OptionalCfg(..) )
26
27
28 -- | The description of the program, displayed as part of the help.
29 --
30 description :: String
31 description =
32 "Monitor a list of Twitter accounts and display or email any new tweets."
33
34
35 -- | The name of this program.
36 --
37 program_name :: String
38 program_name = "halcyon"
39
40
41 -- | A summary string output as part of the help.
42 --
43 my_summary :: String
44 my_summary = program_name ++ "-" ++ (showVersion version)
45
46
47 -- | Help string for the \"consumer_key\" option.
48 --
49 consumer_key_help :: String
50 consumer_key_help = "Your Twitter API consumer key"
51
52
53 -- | Help string for the \"consumer_secret\" option.
54 --
55 consumer_secret_help :: String
56 consumer_secret_help = "Your Twitter API consumer secret"
57
58
59 -- | Help string for the \"access_token\" option
60 --
61 access_token_help :: String
62 access_token_help = "Your Twitter API access token"
63
64
65 -- | Help string for the \"access_secret\" option.
66 --
67 access_secret_help :: String
68 access_secret_help = "Your Twitter API access secret"
69
70
71 -- | Help string for the \"heartbeat\" option.
72 --
73 heartbeat_help :: String
74 heartbeat_help = "How many seconds to wait between polling"
75
76
77 -- | Help string for the \"to_address\" option.
78 --
79 to_address_help :: String
80 to_address_help = "Send tweets to ADDRESS"
81
82
83 -- | Help string for the \"from_address\" option.
84 --
85 from_address_help :: String
86 from_address_help = "Send tweets from ADDRESS"
87
88
89 -- | Help string for the \"sendmail_path\" option.
90 --
91 sendmail_path_help :: String
92 sendmail_path_help = "Use PATH to send mail"
93
94
95 -- | Help string for the \"ignore_replies\" option.
96 --
97 ignore_replies_help :: String
98 ignore_replies_help = "Ignore replies to other tweets"
99
100
101 -- | Help string for the \"ignore_retweets\" option.
102 --
103 ignore_retweets_help :: String
104 ignore_retweets_help = "Ignore retweets from other users"
105
106
107 -- | Help string for the \"verbose\" option.
108 --
109 verbose_help :: String
110 verbose_help = "Be verbose about stuff"
111
112
113 arg_spec :: OptionalCfg
114 arg_spec =
115 OptionalCfg {
116 consumer_key =
117 def &= typ "KEY"
118 &= groupname "Twitter API"
119 &= help consumer_key_help,
120
121 consumer_secret =
122 def &= typ "SECRET"
123 &= groupname "Twitter API"
124 &= help consumer_secret_help,
125
126 access_token =
127 def &= typ "TOKEN"
128 &= groupname "Twitter API"
129 &= help access_token_help,
130
131 access_secret =
132 def &= typ "SECRET"
133 &= groupname "Twitter API"
134 &= help access_secret_help,
135
136 heartbeat =
137 def &= groupname "Miscellaneous"
138 &= help heartbeat_help,
139
140 ignore_replies =
141 def &= groupname "Miscellaneous"
142 &= help ignore_replies_help,
143
144 ignore_retweets =
145 def &= groupname "Miscellaneous"
146 &= help ignore_retweets_help,
147
148 verbose =
149 def &= groupname "Miscellaneous"
150 &= help verbose_help,
151
152 sendmail_path =
153 def &= typ "PATH"
154 &= groupname "Mail Options"
155 &= help sendmail_path_help,
156
157 from_address =
158 def &= typ "ADDRESS"
159 &= groupname "Mail Options"
160 &= help from_address_help,
161
162 to_address =
163 def &= typ "ADDRESS"
164 &= groupname "Mail Options"
165 &= help to_address_help,
166
167 usernames =
168 def &= args
169 &= typ "USERNAMES" }
170
171 &= program program_name
172 &= summary my_summary
173 &= details [description]
174 &= helpArg [groupname "Common flags"]
175 &= versionArg [groupname "Common flags"]
176
177 show_help :: IO OptionalCfg
178 show_help = withArgs ["--help"] get_args
179
180
181 get_args :: IO OptionalCfg
182 get_args = cmdArgs arg_spec