]> gitweb.michael.orlitzky.com - email-validator.git/blob - src/CommandLine.hs
email-validator.cabal: bump to version 1.1.0
[email-validator.git] / src / CommandLine.hs
1 {-# LANGUAGE DeriveDataTypeable #-}
2
3 module CommandLine (
4 Args(..),
5 get_args )
6 where
7
8 import System.Console.CmdArgs (
9 Data,
10 (&=),
11 cmdArgs,
12 def,
13 details,
14 help,
15 program,
16 summary )
17
18
19 -- Get the version from Cabal.
20 import Paths_email_validator ( version )
21 import Data.Version ( showVersion )
22
23
24 data Args = Args { accept_a :: Bool,
25 rfc5322 :: Bool }
26 deriving (Show, Data)
27
28 description :: String
29 description = "Perform naive validation of email addresses."
30
31 program_name :: String
32 program_name = "email-validator"
33
34 my_summary :: String
35 my_summary = program_name ++ "-" ++ (showVersion version)
36
37 accept_a_help :: String
38 accept_a_help =
39 "Accept an 'A' record for the domain instead of requiring an MX record."
40
41 rfc5322_help :: String
42 rfc5322_help =
43 "Validate according to RFC 5322 (incredibly lenient)."
44
45 arg_spec :: Args
46 arg_spec =
47 Args { accept_a = def &= help accept_a_help,
48 rfc5322 = def &= help rfc5322_help }
49 &= program program_name
50 &= summary my_summary
51 &= details [description]
52
53
54
55 get_args :: IO Args
56 get_args = cmdArgs arg_spec