]> gitweb.michael.orlitzky.com - haeredes.git/blobdiff - src/CommandLine.hs
Add a "timeout" command-line argument.
[haeredes.git] / src / CommandLine.hs
index 0ea89a0173c56456162c10ab882dc1dc35e84341..b94e378e516517e5c9d116fae5fe6979876b509e 100644 (file)
@@ -30,6 +30,8 @@ import System.Console.CmdArgs (
 import Paths_haeredes (version)
 import Data.Version (showVersion)
 
+import Timeout (Timeout(..))
+
 -- | Description of the 'NS' mode.
 ns_description :: String
 ns_description =
@@ -48,13 +50,20 @@ my_summary = program_name ++ "-" ++ (showVersion version)
 
 no_append_root_help :: String
 no_append_root_help =
-  "Don't append a trailing dot to DNS names."
+  "Don't append a trailing dot to DNS names"
 
 -- | Help string for the --server flag.
 server_help :: String
 server_help =
   "IP address or hostname of server to query " ++
-  "(will use resolv.conf if not specified)."
+  "(will use resolv.conf if not specified)"
+
+-- | Help string for the --timeout flag.
+timeout_help :: String
+timeout_help =
+  "Query timeout, in seconds (default: " ++ defstr ++ ")"
+  where
+    defstr = show $ seconds (def :: Timeout)
 
 -- | The Args type represents the possible command-line options. The
 --   duplication here seems necessary; CmdArgs' magic requires us to
@@ -62,9 +71,11 @@ server_help =
 data Args =
   NS { no_append_root :: Bool,
        server :: Maybe String,
+       timeout :: Timeout,
        delegates :: [String] } |
   MX { no_append_root :: Bool,
        server :: Maybe String,
+       timeout :: Timeout,
        delegates :: [String] }
   deriving (Data, Show, Typeable)
 
@@ -91,9 +102,14 @@ arg_spec =
 
            server = def
                  &= groupname "Common flags"
-                 &= typ "IP"
+                 &= typ "HOST"
                  &= help server_help,
 
+           timeout = def
+                   &= groupname "Common flags"
+                   &= typ "SECONDS"
+                   &= help timeout_help,
+
            delegates = def
                     &= args
                     &= typ "DELEGATES" }
@@ -111,6 +127,11 @@ arg_spec =
                  &= typ "IP"
                  &= help server_help,
 
+           timeout = def
+                   &= groupname "Common flags"
+                   &= typ "SECONDS"
+                   &= help timeout_help,
+
            delegates = def
                     &= args
                     &= typ "DELEGATES" }