1
0
Fork 0
mirror of https://github.com/Luzifer/cmd-slack.git synced 2024-12-22 18:51:18 +00:00

Added flag to add a description

This commit is contained in:
Knut Ahlers 2016-05-22 20:23:10 +02:00
parent b7074fdf7c
commit 850343fb2e
Signed by: luzifer
GPG key ID: DC2729FDD34BE99E

16
main.go
View file

@ -14,10 +14,11 @@ import (
var ( var (
cfg = struct { cfg = struct {
Hook string `flag:"hook,h" default:"" description:"Slack incoming webhook"` Hook string `flag:"hook,h" default:"" description:"Slack incoming webhook"`
Username string `flag:"username,u" default:"CmdSlack" description:"Username to use in WebHook command"` Username string `flag:"username,u" default:"CmdSlack" description:"Username to use in WebHook command"`
Icon string `flag:"icon,i" default:":package:" description:"Icon to use for the webhook"` Icon string `flag:"icon,i" default:":package:" description:"Icon to use for the webhook"`
Channel string `flag:"channel,c" default:"" description:"Channel to send the message to"` Channel string `flag:"channel,c" default:"" description:"Channel to send the message to"`
Description string `flag:"description,d" default:"" description:"Add a piece of text to prepent to the output"`
}{} }{}
version = "dev" version = "dev"
@ -46,11 +47,16 @@ func main() {
os.Exit(0) os.Exit(0)
} }
text := "```\n" + buf.String() + "```"
if cfg.Description != "" {
text = cfg.Description + "\n" + text
}
slo := slack{ slo := slack{
Username: cfg.Username, Username: cfg.Username,
Icon: cfg.Icon, Icon: cfg.Icon,
Channel: cfg.Channel, Channel: cfg.Channel,
Text: "```\n" + buf.String() + "```", Text: text,
} }
body := bytes.NewBuffer([]byte{}) body := bytes.NewBuffer([]byte{})