-
Notifications
You must be signed in to change notification settings - Fork 91
/
Thorfile
41 lines (31 loc) · 985 Bytes
/
Thorfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# -*- ruby -*-
require 'rubygems'
require 'bundler/setup'
require 'shellwords'
class Cookbook < Thor
COOKBOOK_NAME = 'hostname'.freeze
COOKBOOK_CATEGORY = 'utilities'.freeze
include Thor::Actions
desc :edit, 'Edit cookbook in browser'
def edit
open "http://community.opscode.com/cookbooks/#{COOKBOOK_NAME}/edit"
end
desc :browse, "Go to cookbook's page on Opscode's community website"
def browse
open "http://community.opscode.com/cookbooks/#{COOKBOOK_NAME}/"
end
desc :upload, "Upload cookbook to Opscode's community website"
def upload
run "knife cookbook site share #{COOKBOOK_NAME} #{Shellwords.escape(COOKBOOK_CATEGORY)} -o #{Shellwords.escape(File.dirname(File.dirname(__FILE__)))}"
end
private
def open(what)
run "#{open_cmd} #{Shellwords.escape(what)}"
end
def open_cmd
@open_cmd ||= %w[open xdg-open].find do |command|
system "which #{command} >/dev/null 2>&1"
$CHILD_STATUS.success?
end
end
end