-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Major rewrite of the CLI and added stats
- Loading branch information
Mike Farmer
committed
Dec 17, 2010
1 parent
cbe6a93
commit 1dd0e71
Showing
21 changed files
with
633 additions
and
164 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 |
---|---|---|
@@ -1 +1,3 @@ | ||
*.gem | ||
.rvmrc* | ||
|
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,18 @@ | ||
# A sample Gemfile | ||
source "http://rubygems.org" | ||
|
||
gem "terminal-table" | ||
path "/Users/mikefarmer/Dropbox/Kynetx/oss/am_api_gem" do | ||
gem "kynetx_am_api" | ||
end | ||
gem "sinatra" | ||
gem "launchy" | ||
gem "awesome_print" | ||
gem "thor" | ||
|
||
group :development do | ||
gem "rspec", ">= 2.0.0" | ||
gem "guard-rspec" | ||
gem "rb-fsevent" | ||
gem "growl" | ||
end |
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,60 @@ | ||
PATH | ||
remote: /Users/mikefarmer/Dropbox/Kynetx/oss/am_api_gem | ||
specs: | ||
kynetx_am_api (0.1.29) | ||
json | ||
multipart-post | ||
oauth | ||
|
||
GEM | ||
remote: http://rubygems.org/ | ||
specs: | ||
awesome_print (0.3.1) | ||
configuration (1.2.0) | ||
diff-lcs (1.1.2) | ||
growl (1.0.3) | ||
guard (0.2.2) | ||
open_gem (~> 1.4.2) | ||
thor (~> 0.14.3) | ||
guard-rspec (0.1.9) | ||
guard (>= 0.2.2) | ||
json (1.4.6) | ||
launchy (0.3.7) | ||
configuration (>= 0.0.5) | ||
rake (>= 0.8.1) | ||
multipart-post (1.0.1) | ||
oauth (0.4.4) | ||
open_gem (1.4.2) | ||
launchy (~> 0.3.5) | ||
rack (1.2.1) | ||
rake (0.8.7) | ||
rb-fsevent (0.3.9) | ||
rspec (2.3.0) | ||
rspec-core (~> 2.3.0) | ||
rspec-expectations (~> 2.3.0) | ||
rspec-mocks (~> 2.3.0) | ||
rspec-core (2.3.0) | ||
rspec-expectations (2.3.0) | ||
diff-lcs (~> 1.1.2) | ||
rspec-mocks (2.3.0) | ||
sinatra (1.1.0) | ||
rack (~> 1.1) | ||
tilt (~> 1.1) | ||
terminal-table (1.4.2) | ||
thor (0.14.6) | ||
tilt (1.1) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
awesome_print | ||
growl | ||
guard-rspec | ||
kynetx_am_api! | ||
launchy | ||
rb-fsevent | ||
rspec (>= 2.0.0) | ||
sinatra | ||
terminal-table | ||
thor |
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 |
---|---|---|
@@ -1,34 +1,10 @@ | ||
#!/usr/bin/env ruby | ||
require 'rubygems' | ||
#$DEBUG = true | ||
LIB_DIR = File.dirname(__FILE__) + "/../lib/" | ||
|
||
COMMANDS = { | ||
"help" => lambda { |args| require LIB_DIR + 'help'; KRL_CMD::Help.go }, | ||
"apps" => lambda { |args| require LIB_DIR + 'apps'; KRL_CMD::Apps.go }, | ||
"checkout" => lambda { |args| require LIB_DIR + 'checkout'; KRL_CMD::Checkout.go(args) }, | ||
"create" => lambda { |args| require LIB_DIR + 'create'; KRL_CMD::Create.go(args) }, | ||
"update" => lambda { |args| require LIB_DIR + 'update'; KRL_CMD::Update.go(args) }, | ||
"versions" => lambda { |args| require LIB_DIR + 'versions'; KRL_CMD::Versions.go(args) }, | ||
"deploy" => lambda { |args| require LIB_DIR + 'deploy'; KRL_CMD::Deploy.go(args) }, | ||
"commit" => lambda { |args| require LIB_DIR + 'commit'; KRL_CMD::Commit.go(args) }, | ||
"show" => lambda { |args| require LIB_DIR + 'show'; KRL_CMD::Show.go(args) }, | ||
"note" => lambda { |args| require LIB_DIR + 'note'; KRL_CMD::Note.go(args) }, | ||
"check" => lambda { |args| require LIB_DIR + 'check'; KRL_CMD::Check.go(args) }, | ||
"generate" => lambda { |args| require LIB_DIR + 'generate'; KRL_CMD::Generate.go(args) }, | ||
"test" => lambda { |args| require LIB_DIR + 'test'; KRL_CMD::Test.go(args) }, | ||
"info" => lambda { |args| require LIB_DIR + 'info'; KRL_CMD::Info.go(args) } | ||
} | ||
require 'bundler/setup' | ||
require 'thor' | ||
require 'ap' | ||
|
||
banner = "Usage: krl <command> <args>\nUse 'krl help' for more information." | ||
#$DEBUG = true | ||
|
||
cmd = ARGV.shift | ||
if COMMANDS.keys.include? cmd | ||
begin | ||
COMMANDS[cmd].call(ARGV) | ||
rescue Exception => e | ||
puts "Error: #{e.message}" | ||
end | ||
else | ||
puts banner | ||
end | ||
require File.dirname(__FILE__) + "/../lib/cli" | ||
KRL_CMD::CLI.start |
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
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
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
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
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 |
---|---|---|
@@ -1,32 +1,67 @@ | ||
require LIB_DIR + 'user' | ||
require 'fileutils' | ||
|
||
module KRL_CMD | ||
class Checkout | ||
def self.go(args) | ||
require LIB_DIR + 'common' | ||
|
||
def self.go(ruleset, options) | ||
begin | ||
c = self.new(ruleset, options) | ||
c.checkout | ||
rescue Exception => e | ||
puts e.message | ||
ap e.backtrace if $DEBUG | ||
end | ||
end | ||
|
||
def initialize(ruleset, options) | ||
@user = User.new | ||
@ruleset = ruleset | ||
@include_title = options["title"] | ||
@all = options["all"] | ||
app = KRL_COMMON::get_app rescue nil | ||
raise "You are already in an application: #{app.application_id}" if app | ||
|
||
ruleset_id = args.to_s | ||
puts "Checking out: #{ruleset_id}" | ||
raise "Please specify a ruleset id." if ruleset_id.empty? | ||
root_dir = Dir.pwd + "/#{ruleset_id}" | ||
raise "Directory already exists." if File.exists?(root_dir) | ||
user = User.new | ||
app = user.find_application({:application_id => ruleset_id}) | ||
|
||
puts "Creating directory: #{root_dir}" | ||
FileUtils.mkdir root_dir | ||
app_details = { | ||
:name => app.name, | ||
:ruleset_id => app.application_id, | ||
:role => user.owns_current? ? "owner" : "developer" | ||
} | ||
File.open(root_dir + "/.app", "w") { |f| f.print(app_details.to_yaml) } | ||
File.open(root_dir + "/#{ruleset_id}.krl", "w") { |f| f.print(app.krl) } | ||
raise "You are already in an application directory: #{app.application_id}" if app | ||
end | ||
|
||
def checkout | ||
|
||
if @all | ||
@user.applications["apps"].each do |app| | ||
begin | ||
@ruleset = app["appid"] | ||
do_checkout | ||
rescue => e | ||
puts e.message | ||
end | ||
end | ||
else | ||
do_checkout | ||
end | ||
|
||
|
||
end | ||
|
||
private | ||
|
||
def do_checkout | ||
app = @user.find_application({:application_id => @ruleset}) | ||
if app | ||
dir_name = @include_title && app.name ? "#{@ruleset}-#{app.name}" : @ruleset | ||
puts "Checking out: #{dir_name}" | ||
root_dir = Dir.pwd + "/#{dir_name}" | ||
raise "Directory already exists (#{root_dir})." if File.exists?(root_dir) | ||
|
||
puts "Creating directory: #{root_dir}" | ||
FileUtils.mkdir root_dir | ||
app_details = { | ||
:name => app.name, | ||
:ruleset_id => app.application_id, | ||
:role => @user.owns_current? ? "owner" : "developer" | ||
} | ||
File.open(root_dir + "/.app", "w") { |f| f.print(app_details.to_yaml) } | ||
File.open(root_dir + "/#{app.application_id}.krl", "w") { |f| f.print(app.krl) } | ||
else | ||
puts "Unable to find ruleset #{@ruleset}. You probably don't have permission to check it out." | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.