Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 79cc168
Showing
2 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |