]> gitweb.michael.orlitzky.com - dead/halcyon.git/blobdiff - src/CommandLine.hs
Add configuration options for daemonize, pidfile, run_as_group and run_as_user.
[dead/halcyon.git] / src / CommandLine.hs
index 01b5a806219e8f131fc69b9a7646f64890e3b02e..45d43abe41dc5082d6edcf3b71267b32c18f4c43 100644 (file)
@@ -15,6 +15,7 @@ import System.Console.CmdArgs (
   program,
   summary,
   typ,
+  typFile,
   versionArg )
 import System.Environment ( withArgs )
 
@@ -44,16 +45,10 @@ my_summary :: String
 my_summary = program_name ++ "-" ++ (showVersion version)
 
 
--- | Help string for the \"consumer_key\" option.
---
-consumer_key_help :: String
-consumer_key_help = "Your Twitter API consumer key"
-
-
--- | Help string for the \"consumer_secret\" option.
+-- | Help string for the \"access_secret\" option.
 --
-consumer_secret_help :: String
-consumer_secret_help = "Your Twitter API consumer secret"
+access_secret_help :: String
+access_secret_help = "Your Twitter API access secret"
 
 
 -- | Help string for the \"access_token\" option
@@ -62,22 +57,22 @@ access_token_help :: String
 access_token_help = "Your Twitter API access token"
 
 
--- | Help string for the \"access_secret\" option.
+-- | Help string for the \"consumer_key\" option.
 --
-access_secret_help :: String
-access_secret_help = "Your Twitter API access secret"
+consumer_key_help :: String
+consumer_key_help = "Your Twitter API consumer key"
 
 
--- | Help string for the \"heartbeat\" option.
+-- | Help string for the \"consumer_secret\" option.
 --
-heartbeat_help :: String
-heartbeat_help = "How many seconds to wait between polling"
+consumer_secret_help :: String
+consumer_secret_help = "Your Twitter API consumer secret"
 
 
--- | Help string for the \"to_address\" option.
+-- | A description of the \"daemonize\" option.
 --
-to_address_help :: String
-to_address_help = "Send tweets to ADDRESS"
+daemonize_help :: String
+daemonize_help = "Run as a daemon, in the background."
 
 
 -- | Help string for the \"from_address\" option.
@@ -86,10 +81,10 @@ from_address_help :: String
 from_address_help = "Send tweets from ADDRESS"
 
 
--- | Help string for the \"sendmail_path\" option.
+-- | Help string for the \"heartbeat\" option.
 --
-sendmail_path_help :: String
-sendmail_path_help = "Use PATH to send mail"
+heartbeat_help :: String
+heartbeat_help = "How many seconds to wait between polling"
 
 
 -- | Help string for the \"ignore_replies\" option.
@@ -104,6 +99,37 @@ ignore_retweets_help :: String
 ignore_retweets_help = "Ignore retweets from other users"
 
 
+-- | A description of the "pidfile" option.
+pidfile_help :: String
+pidfile_help =
+  "Location to create PID file (daemon only)."
+
+
+-- | A description of the "run_as_group" option.
+run_as_group_help :: String
+run_as_group_help =
+  "System group to run as (daemon only)."
+
+
+-- | A description of the "run_as_user" option.
+run_as_user_help :: String
+run_as_user_help =
+  "System user to run under (daemon only)."
+
+
+-- | Help string for the \"to_address\" option.
+--
+to_address_help :: String
+to_address_help = "Send tweets to ADDRESS"
+
+
+
+-- | Help string for the \"sendmail_path\" option.
+--
+sendmail_path_help :: String
+sendmail_path_help = "Use PATH to send mail"
+
+
 -- | Help string for the \"verbose\" option.
 --
 verbose_help :: String
@@ -113,25 +139,36 @@ verbose_help = "Be verbose about stuff"
 arg_spec :: OptionalCfg
 arg_spec =
   OptionalCfg {
-    consumer_key =
-      def &= typ "KEY"
-          &= groupname "Twitter API"
-          &= help consumer_key_help,
 
-    consumer_secret =
+   access_secret =
       def &= typ "SECRET"
           &= groupname "Twitter API"
-          &= help consumer_secret_help,
+          &= help access_secret_help,
 
     access_token =
       def &= typ "TOKEN"
           &= groupname "Twitter API"
           &= help access_token_help,
 
-    access_secret =
+    consumer_key =
+      def &= typ "KEY"
+          &= groupname "Twitter API"
+          &= help consumer_key_help,
+
+    consumer_secret =
       def &= typ "SECRET"
           &= groupname "Twitter API"
-          &= help access_secret_help,
+          &= help consumer_secret_help,
+
+
+   daemonize =
+      def &= groupname "Miscellaneous"
+          &= help daemonize_help,
+
+   from_address =
+      def &= typ "ADDRESS"
+          &= groupname "Mail Options"
+          &= help from_address_help,
 
     heartbeat =
       def &= groupname "Miscellaneous"
@@ -145,20 +182,23 @@ arg_spec =
       def &= groupname "Miscellaneous"
           &= help ignore_retweets_help,
 
-    verbose =
-      def &= groupname "Miscellaneous"
-          &= help verbose_help,
+    pidfile =
+      def &= typFile
+          &= help pidfile_help,
+
+    run_as_group =
+      def &= typ "GROUP"
+          &= help run_as_group_help,
+
+    run_as_user =
+      def &= typ "USER"
+          &= help run_as_user_help,
 
     sendmail_path =
       def &= typ "PATH"
           &= groupname "Mail Options"
           &= help sendmail_path_help,
 
-    from_address =
-      def &= typ "ADDRESS"
-          &= groupname "Mail Options"
-          &= help from_address_help,
-
     to_address =
       def &= typ "ADDRESS"
           &= groupname "Mail Options"
@@ -166,7 +206,11 @@ arg_spec =
 
     usernames =
       def &= args
-          &= typ "USERNAMES" }
+          &= typ "USERNAMES",
+
+    verbose =
+      def &= groupname "Miscellaneous"
+          &= help verbose_help }
 
   &= program program_name
   &= summary my_summary
@@ -174,6 +218,7 @@ arg_spec =
   &= helpArg [groupname "Common flags"]
   &= versionArg [groupname "Common flags"]
 
+
 show_help :: IO OptionalCfg
 show_help = withArgs ["--help"] get_args