Permalink
Browse files

Playing with some sub commands

  • Loading branch information...
1 parent d5ae7df commit b8cd57974b6c9cc0c78a6580fbb88216695492f9 @pengwynn committed Dec 10, 2012
Showing with 41 additions and 0 deletions.
  1. +31 −0 wynn/libexec/wynn-status
  2. +10 −0 wynn/libexec/wynn-vanity
View
31 wynn/libexec/wynn-status
@@ -0,0 +1,31 @@
+#!/usr/bin/env ruby
+# Usage: wynn status [all]
+# Summary: Check GitHub system status
+# Help: https://status.github.com/api
+#
+# encoding: utf-8
+require 'json'
+
+%w(json open-uri).each { |lib| require lib }
+
+def display_status(status)
+ color = case status['status']
+ when 'good'
+ "\e[32m"
+ when 'minor'
+ "\e[33m"
+ when 'major'
+ "\e[31m"
+ end
+ timestamp = Time.parse status['created_on']
+ puts "#{timestamp.to_s} #{color}#{status['body']}\e[0m"
+end
+
+response = open("https://status.github.com/api/messages.json").read
+
+statuses = JSON.parse(response)
+if ARGV.first == 'all'
+ statuses.each { |s| display_status s }
+else
+ display_status statuses.first
+end
View
10 wynn/libexec/wynn-vanity
@@ -0,0 +1,10 @@
+#!/usr/bin/env bash
+# Usage: wynn vanity
+# Summary: Check Twitter followers count
+# Help: Uses the t gem to check followers for a given Twitter user
+#
+# wynn vanity [username]
+
+set -e
+USERNAME=${1:-"pengwynn"}
+echo $USERNAME $(t user $USERNAME | grep Followers | cut -d " " -f 5)

0 comments on commit b8cd579

Please sign in to comment.