The code files for chapter 8 of B18275 have been added on a separate repository of its own.
The tweeter command line tool will send a tweet via Twitter.
You can use tweeter to send a tweet or to output the message to STDOUT. If you want to send a tweet, you will need to set up a Twitter application.
To send a tweet, you will need to create or use an existing Twitter account, create a Twitter application, and generate API credentials. All of this can be done through the Twitter Developer Portal.
Some people may not want to set up a Twitter account. If you would like to use tweeter without sending tweets, use the --dry-run
argument. This will cause the tool to write the message to STDOUT rather than sending the message to Twitter.
--message
Required the tweet message you would like to send--apiKey
the API key under Consumer Keys in the Twitter developer portal--apiKeySecret
the API key secret under Consumer Keys in the Twitter developer portal--accessToken
the access token under Authentication Tokens in the Twitter developer portal--accessTokenSecret
the access token secret under Authentications Tokens in the Twitter developer portal--dryRun
will skip authentication validation and sending the message to Twitter
$ go test ./...
? github.com/devopsforgo/github-actions [no test files]
ok github.com/devopsforgo/github-actions/pkg/tweeter 0.002s
To see the command line arguments and descriptions, display the help.
$ go run . -h
Usage of /tmp/go-build3731631588/b001/exe/github-actions:
--accessToken string twitter access token
--accessTokenSecret string twitter access token secret
--apiKey string twitter api key
--apiKeySecret string twitter api key secret
--dryRun if true, then a tweet will not be sent
--message string message you'd like to send to twitter
pflag: help requested
exit status 2
The --dryRun
argument will skip validation of the authentication arguments and output the message to STDOUT.
$ go run . --dryRun --message foo
Without --dryRun
specified, tweeter will send the --messsage
argument as a Tweet.
$ go run . --message foo --apiKey 123 --apiKeySecret secret --accessToken token --accessTokenSecret secret