mirror of
https://github.com/Luzifer/cmd-slack.git
synced 2024-12-22 10:41:23 +00:00
Added flag to add a description
This commit is contained in:
parent
b7074fdf7c
commit
850343fb2e
1 changed files with 11 additions and 5 deletions
16
main.go
16
main.go
|
@ -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{})
|
||||||
|
|
Loading…
Reference in a new issue