]> gitweb.michael.orlitzky.com - dead/htsn.git/blob - src/CommandLine.hs
Tiny change to the description used in CmdArgs.
[dead/htsn.git] / src / CommandLine.hs
1 -- | Parse the command-line options, and display help text if
2 -- necessary.
3 module CommandLine (
4 get_args )
5 where
6
7 import System.Console.CmdArgs (
8 (&=),
9 cmdArgs,
10 def,
11 details,
12 help,
13 program,
14 summary,
15 typ,
16 typDir )
17
18 -- This let's us get the version from Cabal.
19 import Paths_htsn (version)
20 import Data.Version (showVersion)
21
22 import OptionalConfiguration (OptionalConfiguration(..))
23
24
25 -- | The description of the program, displayed as part of the help.
26 description :: String
27 description = "Parse XML files from The Sports Network feed."
28
29 -- | The name of this program.
30 program_name :: String
31 program_name = "htsn"
32
33 -- | A summary string output as part of the help.
34 my_summary :: String
35 my_summary = program_name ++ "-" ++ (showVersion version)
36
37
38 -- | A description of the "password" option.
39 password_help :: String
40 password_help =
41 "Password to use when connecting to the feed"
42
43 -- | A description of the "output_directory" option.
44 output_directory_help :: String
45 output_directory_help =
46 "Directory in which to output the XML files; must be writable"
47
48 -- | A description of the "username" option.
49 username_help :: String
50 username_help =
51 "Username to use when connecting to the feed"
52
53 -- | A data structure representing the possible command-line
54 -- options. The CmdArgs library is doing heavy magic beneath the
55 -- hood here.
56 arg_spec :: OptionalConfiguration
57 arg_spec =
58 OptionalConfiguration {
59 password = def &= typ "PASSWORD" &= help password_help,
60 output_directory = def &= typDir &= help output_directory_help,
61 username = def &= typ "USERNAME" &= help username_help,
62 feed_hosts = def &= typ "HOSTNAMES" }
63 &= program program_name
64 &= summary my_summary
65 &= details [description]
66
67
68 -- | A convenience function; our only export. Meant to be used in
69 -- 'main' to retrieve the command-line arguments.
70 get_args :: IO OptionalConfiguration
71 get_args = cmdArgs arg_spec