packages feed

hsendxmpp 0.1.0.0 → 0.1.1.0

raw patch · 3 files changed

+20/−10 lines, 3 files

Files

− CHANGELOG.md
@@ -1,5 +0,0 @@-# Revision history for hsendxmpp--## 0.1.0.0 -- YYYY-mm-dd--* First version. Released on an unsuspecting world.
Main.hs view
@@ -2,6 +2,7 @@  module Main where +import Data.Maybe import qualified Data.String.Class as S import Network.Xmpp import Network.Xmpp.Internal hiding (priority, status)@@ -9,6 +10,8 @@ import System.Environment  +passWordEnvVar = "HSENDXMPP_PASSWORD"+ data Options = Options 	{ oUserName :: String 	, oPassWord :: String@@ -24,7 +27,7 @@ options :: [OptDescr (Options -> Options)] options = 	[ Option ['u']	["username"]	(ReqArg	(\str o -> o { oUserName = str }) "user")	"Use this username to authenticate to the server"-	, Option ['p']	["password"]	(ReqArg	(\str o -> o { oPassWord = str }) "password")	"Use this password to authenticate to the server"+	, Option ['p']	["password"]	(ReqArg	(\str o -> o { oPassWord = str }) "password") $	"Use this password to authenticate to the server.\nThe password can also be provided via " ++ passWordEnvVar ++ " environment variable to avoid it leaking into process lists, and it will override the CLI option contents." 	, Option ['j']	["jserver"]	(ReqArg	(\str o -> o { oServer = str }) "server")	"Connect to this server" 	] @@ -34,13 +37,17 @@ 	pn <- getProgName 	case getOpt Permute options args of 		(o,n,[]  ) -> return (foldl (flip id) defaultOptions o, n)-		(_,_,errs) -> ioError (userError (concat errs ++ usageInfo ("Usage: " ++ pn ++ " <recipient>") options))+		(_,_,errs) -> ioError (userError (concat errs ++ usageInfo ("Usage: " ++ pn ++ " [options] <recipient1> [<recipient2> ...]") options))  main :: IO () main = do 	(opts, recipients) <- getOpts 	text <- getContents-	eSess <- session (oServer opts) (simpleAuth (S.toText $ oUserName opts) (S.toText $ oPassWord opts)) def+	envPassWord <- lookupEnv passWordEnvVar+	let justEnvPassWord = fromMaybe "" envPassWord+	let passWord = if null justEnvPassWord then oPassWord opts else justEnvPassWord++	eSess <- session (oServer opts) (simpleAuth (S.toText $ oUserName opts) (S.toText passWord)) def 	let sess = either (error . show) id $ eSess 	sendPresence presenceOnline sess 	mapM_ (\tjid -> sendMessage ((simpleIM (parseJid tjid) $ S.toText text) { messageType = Chat }) sess >> pure ()) recipients
hsendxmpp.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                hsendxmpp-version:             0.1.0.0+version:             0.1.1.0 synopsis:            sendxmpp clone, sending XMPP messages via CLI -- description: license:             OtherLicense@@ -12,8 +12,16 @@ -- copyright: category:            Network build-type:          Simple-extra-source-files:  CHANGELOG.md cabal-version:       >=1.10++Source-repository head+  type:              git+  location:          https://github.com/l29ah/hsendxmpp.git++Source-repository this+  type:              git+  location:          https://github.com/l29ah/hsendxmpp.git+  tag:               0.1.1.0  executable hsendxmpp   main-is:             Main.hs