1 {-# LANGUAGE DeriveDataTypeable #-}
9 import System.Console.CmdArgs (
29 -- Get the version from Cabal.
30 import Paths_haeredes (version)
31 import Data.Version (showVersion)
33 import Timeout (Timeout(..))
35 -- | Description of the 'NS' mode.
36 ns_description :: String
38 "Confirm delegation of NS records. " ++
39 "This is the default mode."
41 -- | Description of the 'MX' mode.
42 mx_description :: String
43 mx_description = "Confirm delegation of MX records."
45 program_name :: String
46 program_name = "haeredes"
49 my_summary = program_name ++ "-" ++ (showVersion version)
51 no_append_root_help :: String
53 "Don't append a trailing dot to DNS names"
55 -- | Help string for the --server flag.
58 "IP address or hostname of server to query " ++
59 "(will use resolv.conf if not specified)"
61 -- | Help string for the --timeout flag.
62 timeout_help :: String
64 "Query timeout, in seconds (default: " ++ defstr ++ ")"
66 defstr = show $ seconds (def :: Timeout)
68 -- | The Args type represents the possible command-line options. The
69 -- duplication here seems necessary; CmdArgs' magic requires us to
70 -- define some things explicitly.
72 NS { no_append_root :: Bool,
73 server :: Maybe String,
75 delegates :: [String] } |
76 MX { no_append_root :: Bool,
77 server :: Maybe String,
79 delegates :: [String] }
80 deriving (Data, Show, Typeable)
84 modes [ns &= auto, mx]
85 &= program program_name
90 groupname "Common flags"]
91 &= versionArg [explicit,
94 groupname "Common flags"]
96 -- The repetition here is necessary, some CmdArgs magic going on.
100 &= groupname "Common flags"
101 &= help no_append_root_help,
104 &= groupname "Common flags"
109 &= groupname "Common flags"
111 &= help timeout_help,
117 &= details [ns_description]
122 &= groupname "Common flags"
123 &= help no_append_root_help,
126 &= groupname "Common flags"
131 &= groupname "Common flags"
133 &= help timeout_help,
139 &= details [mx_description]
142 get_args = cmdArgs arg_spec