From e3e57ac80340974c3b2e903d863ee8af826af2ab Mon Sep 17 00:00:00 2001 From: Martin/Geno Date: Thu, 18 Jul 2019 01:10:03 +0200 Subject: [PATCH] add parameter and config for address to sendxmpp --- cmd/sendxmpp/README.md | 9 +++++++-- cmd/sendxmpp/cmd.go | 4 ++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/cmd/sendxmpp/README.md b/cmd/sendxmpp/README.md index 788f834..11bb1ac 100644 --- a/cmd/sendxmpp/README.md +++ b/cmd/sendxmpp/README.md @@ -21,7 +21,8 @@ Examples: sendxmpp to@chat.sum7.eu "Hello World!" Flags: - --config string config file (default is ~/.config/fluxxmpp.toml) + --addr string host[:port] + --config string config file (default is ~/.config/fluxxmpp.yml) -h, --help help for sendxmpp --jid string using jid (required) -m, --muc reciever is a muc (join it before sending messages) @@ -105,6 +106,8 @@ e.g. ~/.config/fluxxmpp.toml ```toml jid = "bot@example.org" password = "secret" + +addr = "example.com:5222" ``` #### Enviroment variable @@ -112,6 +115,8 @@ password = "secret" export FLUXXMPP_JID='bot@example.org'; export FLUXXMPP_PASSWORD='secret'; +export FLUXXMPP_ADDR='example.com:5222'; + sendxmpp to@example.org "Hello Welt"; ``` @@ -120,5 +125,5 @@ Warning: This should not be used in productiv system. (Every user on the system could read the running processes with parameter - on this way the password) ```bash -sendxmpp to@example.org "Hello Welt" --jid bot@example.org --password secret; +sendxmpp to@example.org "Hello Welt" --jid bot@example.org --password secret --addr example.com:5222; ``` diff --git a/cmd/sendxmpp/cmd.go b/cmd/sendxmpp/cmd.go index 14c5553..33a4f8c 100644 --- a/cmd/sendxmpp/cmd.go +++ b/cmd/sendxmpp/cmd.go @@ -39,6 +39,7 @@ var cmd = &cobra.Command{ var err error client, err := xmpp.NewClient(xmpp.Config{ Jid: viper.GetString("jid"), + Address: viper.GetString("addr"), Password: viper.GetString("password"), }, xmpp.NewRouter()) @@ -97,6 +98,9 @@ func init() { cmd.Flags().StringP("password", "", "", "using password for your jid (required)") viper.BindPFlag("password", cmd.Flags().Lookup("password")) + cmd.Flags().StringP("addr", "", "", "host[:port]") + viper.BindPFlag("addr", cmd.Flags().Lookup("addr")) + cmd.Flags().BoolVarP(&stdIn, "stdin", "i", false, "read from stdin instatt of 2. argument") cmd.Flags().BoolVarP(&receiverMUC, "muc", "m", false, "reciever is a muc (join it before sending messages)") }