Created
November 13, 2015 22:42
-
-
Save evadnoob/f40905f4432e5fe44256 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# | |
require 'json' | |
require "docopt" | |
doc = <<DOCOPT | |
Hipchat cli | |
Usage: | |
#{__FILE__} --auth-token=<auth_token> notify [--type=<type>] [--state=<state>] --room=<room> <message> [--dry-run] | |
#{__FILE__} -h | --help | |
#{__FILE__} --version | |
Options: | |
--auth-token=<auth_token> API Authorization token | |
-h --help Show this screen. | |
--version Show version. | |
DOCOPT | |
begin | |
require "pp" | |
options = Docopt::docopt(doc) | |
pp options | |
auth_token = options['--auth-token'] | |
room = options['--room'] | |
message = options['<message>'] | |
dry_run = options['--dry-run'] | |
data = { | |
:color => "yellow", | |
:notify => false, | |
:message_format => "html", | |
:message => options['<message>'] | |
} | |
result = `curl -v -H 'Content-Type: application/json' -d '#{JSON.generate(data)}' 'https://api.hipchat.com/v2/room/#{room}/notification?auth_token=#{auth_token}'` | |
rescue Docopt::Exit => e | |
puts e.message | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment