Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

initial setup

  • Loading branch information...
commit 79cc1686f919b00ffd0336fe79c2646afde86456 0 parents
@geemus authored
Showing with 80 additions and 0 deletions.
  1. +30 −0 README.md
  2. +50 −0 init.rb
30 README.md
@@ -0,0 +1,30 @@
+# heroku-docs
+
+## Installation
+
+ $ heroku plugins:install http://github.com/geemus/heroku-docs.git
+
+## Usage
+
+ $ heroku docs dynos
+ Opening dynos docs... done
+
+ $ heroku docs dyno
+ ! No dyno article found.
+ ! Perhaps you meant one of these:
+ ! dynos # Dynos and the Dyno Manifold
+ ! dyno-requests # How many requests can a dyno serve?
+ ! addons_with_dyno_hour_usage # Add-ons with Dyno Hour Usage
+ ! how-much-does-a-dyno-cost # How much does a dyno cost?
+ ! scaling-aspen-bamboo # Scaling Dynos and Workers on Aspen/Bamboo
+ ! background-jobs-queueing # Worker Dynos, Background Jobs and Queueing
+ ! usage-and-billing # Usage & Billing
+ ! prorate-charges # How do you prorate charges?
+ ! oneoff-admin-ps # One-off Processes
+ ! key-concepts-performance # Key Concepts in Performance on Bamboo
+ ! backlog-too-deep # Backlog Too Deep
+ ! ssh-access # SSH Access
+ ! maintenance-mode # Maintenance Mode
+ ! ps # Managing Heroku Processes
+ ! erosion-resistance # Erosion-resistance
+
50 init.rb
@@ -0,0 +1,50 @@
+require "heroku/command"
+require "excon"
+
+# access devcenter documentation
+class Heroku::Command::Docs < Heroku::Command::Base
+
+ # docs TOPIC
+ #
+ # get devcenter documentation on TOPIC
+ #
+ def index
+ unless topic = shift_argument
+ error("Usage: heroku docs: TOPIC\nMust specify TOPIC to open docs for.")
+ end
+
+ docs(topic, "https://devcenter.heroku.com/articles/#{topic}")
+ end
+
+ private
+
+ def docs(topic, url)
+ head = Excon.head(url)
+ case head.status
+ when 200
+ action("Opening #{topic} docs") do
+ require('launchy')
+ launchy = Launchy.open(url)
+ if launchy.respond_to?(:join)
+ launchy.join
+ end
+ end
+ when 301, 302
+ docs(head.headers['Location'])
+ when 404
+ message = [
+ "No #{topic} article found."
+ ]
+ suggestions = json_decode(Excon.get('https://devcenter.heroku.com/articles.json', :query => { :q => topic }).body)['devcenter']
+ unless suggestions.empty?
+ message << "Perhaps you meant one of these:"
+ longest = suggestions.map {|suggestion| suggestion['url'].split('/articles/').last.length }.max
+ suggestions.each do |suggestion|
+ message << " %-#{longest}s # %s" % [suggestion['url'].split('/articles/').last, suggestion['title']]
+ end
+ end
+ error(message.join("\n"))
+ end
+ end
+
+end
Please sign in to comment.
Something went wrong with that request. Please try again.