use - instatt of --stdin to detect stdin

disco_info_form
Martin/Geno 5 years ago committed by Mickaël Rémond
parent ff5885f29d
commit 5697d40e5c

@ -27,7 +27,6 @@ Flags:
--jid string using jid (required)
-m, --muc reciever is a muc (join it before sending messages)
--password string using password for your jid (required)
-i, --stdin read from stdin instatt of 2. argument
```
@ -47,7 +46,7 @@ $ sendxmpp to@example.org "Hello Welt"
Message from STDIN:
```bash
$ journalctl -f | sendxmpp to@example.org --stdin
$ journalctl -f | sendxmpp to@example.org -
info client connected
⇢ cmd.go:56 main.glob..func1.1
⇢ 2019-07-17T23:40:03.177+02:00
@ -81,7 +80,7 @@ $ sendxmpp to1@example.org,to2@example.org "Multiple reciever"
Send to MUC:
```bash
journalctl -f | sendxmpp testit@conference.chat.sum7.eu --stdin --muc
journalctl -f | sendxmpp testit@conference.chat.sum7.eu - --muc
info client connected
⇢ cmd.go:56 main.glob..func1.1
⇢ 2019-07-17T23:52:56.269+02:00

@ -19,22 +19,14 @@ var jid = ""
var password = ""
var receiverMUC = false
var stdIn = false
var cmd = &cobra.Command{
Use: "sendxmpp <recieve,> [message]",
Example: `sendxmpp to@chat.sum7.eu "Hello World!"`,
Args: cobra.RangeArgs(1, 2),
Args: cobra.ExactArgs(2),
Run: func(cmd *cobra.Command, args []string) {
receiver := strings.Split(args[0], ",")
msgText := ""
if !stdIn && len(args) < 2 {
log.Error("no message to send")
return
} else if !stdIn {
msgText = args[1]
}
msgText := args[1]
var err error
client, err := xmpp.NewClient(xmpp.Config{
@ -62,7 +54,7 @@ var cmd = &cobra.Command{
}
}
if !stdIn {
if msgText != "-" {
send(c, receiver, msgText)
return
}
@ -101,7 +93,6 @@ func init() {
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)")
}

Loading…
Cancel
Save