X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2FCommandLine.hs;fp=src%2FCommandLine.hs;h=8a2a8116ce607b8db7732061455cfad3615973ae;hb=72482968102ebd7ad0abeef958fed2a02a126dd2;hp=0000000000000000000000000000000000000000;hpb=65ec33ab24068e50612e72e69d893ecac9079cdc;p=mailbox-count.git diff --git a/src/CommandLine.hs b/src/CommandLine.hs new file mode 100644 index 0000000..8a2a811 --- /dev/null +++ b/src/CommandLine.hs @@ -0,0 +1,75 @@ +{-# LANGUAGE DeriveDataTypeable #-} + +module CommandLine ( + get_args ) +where + +import System.Console.CmdArgs ( + (&=), + cmdArgs, + def, + details, + help, + program, + summary ) + + +-- Get the version from Cabal. +import Paths_mailbox_count ( version ) +import Data.Version ( showVersion ) + +import OptionalConfiguration ( OptionalConfiguration(..) ) + + +description :: String +description = "Count mailboxes in a SQL database." + +program_name :: String +program_name = "mailbox-count" + +my_summary :: String +my_summary = program_name ++ "-" ++ (showVersion version) + +both_help :: String +both_help = + "Produce both summary and detailed reports" + +database_help :: String +database_help = + "The name of the database to which we should connect" + +detail_help :: String +detail_help = + "Produce a detailed report listing all mailboxes by domain" + +host_help :: String +host_help = + "Hostname where the database is located" + +password_help :: String +password_help = + "Password used to connect to the database" + +port_help :: String +port_help = + "Port number used to connect to the database" + +username_help :: String +username_help = + "Username used to connect to the database" + +arg_spec :: OptionalConfiguration +arg_spec = OptionalConfiguration + { both = def &= help both_help, + database = def &= help database_help, + detail = def &= help detail_help, + host = def &= help host_help, + password = def &= help password_help, + port = def &= help port_help, + username = def &= help username_help } + &= program program_name + &= summary my_summary + &= details [description] + +get_args :: IO OptionalConfiguration +get_args = cmdArgs arg_spec