/slackcat

Post to Slack from stdin

Primary LanguageGo

slackcat

Post to Slack from stdin.

installation

Grab the latest release from Github.

usage

simple usage

echo "hello" | slackcat -channel=$YOUR_CHANNEL

use token from environment variable (default)

export SLACK_TOKEN=$SLACK_TOKEN
echo "hello" | slackcat -channel=$YOUR_CHANNEL

use token from command line flag

echo "hello" | slackcat -channel=$YOUR_CHANNEL -token=$SLACK_TOKEN

treat stdin as a Slack attachment

cat attachment.json | slackcat -channel=$YOUR_CHANNEL -attachment

Check out the Slack Message Builder to give you an idea. Also please find some simple example JSON below:

{
  "fallback": "Required plain-text summary of the attachment.",
  "color": "#36a64f",
  "title": "Slack API Documentation",
  "title_link": "https://api.slack.com/",
  "text": "Optional text that appears within the attachment",
}

tee stdin to stdout and Slack

echo "hello" | slackcat -channel=$YOUR_CHANNEL -tee

verbose output (print slack API response)

echo "hello" | slackcat -channel=$YOUR_CHANNEL -v

why?

There are lots of repos named slackcat (written in Go even). The one I tried didn't work and it seemed too simple to implement hence the re-write.