]> gitweb.michael.orlitzky.com - haeredes.git/blobdiff - src/CommandLine.hs
Add a "timeout" command-line argument.
[haeredes.git] / src / CommandLine.hs
index 2118f5911ec2c533128f5a5c41530348ca10c362..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 =
@@ -56,15 +58,24 @@ server_help =
   "IP address or hostname of server to query " ++
   "(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
 --   define some things explicitly.
 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)
 
@@ -94,6 +105,11 @@ arg_spec =
                  &= 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" }