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:
parent
b7074fdf7c
commit
850343fb2e
1 changed files with 11 additions and 5 deletions
8
main.go
8
main.go
|
@ -18,6 +18,7 @@ var (
|
||||||
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