0
@@ -10,42 +10,61 @@ class TextmateInstaller < Thor
0
desc "remote [SEARCH]", "Lists all the matching remote bundles"
0
limit = Regexp.new(".*#{limit}.*", "i")
0
- puts "\nBundles\n-------\n"
0
- results = %x[svn list #{svn_for("bundles")}]
0
- puts results.map {|x| x.split(".")[0]}.select {|x| x =~ limit}.join("\n")
0
- puts "\nReview\n------\n"
0
- results = %x[svn list #{svn_for("review")}]
0
- puts results.map {|x| x.split(".")[0]}.select {|x| x =~ limit}.join("\n")
0
+ remote_bundle_locations.each do |name,location|
0
+ puts "\n" << name.to_s << " Remote Bundles\n" << name.to_s.gsub(/./,'-') << '---------------'
0
+ results = %x[svn list #{e_sh location[:url]}] if location[:scm]==:svn
0
+ puts results.map {|x| x.split(".")[0]}.select {|x| x =~ limit}.join("\n") if results
0
+ puts 'git remotes not implemented yet' if location[:scm]==:git
0
desc "list", "lists all the bundles installed locally"
0
- bundles_paths.each do |location,bundles_path|
0
- puts location.to_s << " Bundles\n" << location.to_s.gsub(/./,'-') << '--------'
0
+ local_bundle_paths.each do |name,bundles_path|
0
+ puts "\n" << name.to_s << " Bundles\n" << name.to_s.gsub(/./,'-') << '--------'
0
puts Dir["#{e_sh bundles_path}/*.tmbundle"].map {|x| x.split("/").last.split(".").first}.join("\n")
0
- desc "install NAME", "install a bundle"
0
+ # TODO: Add a DESTINATION option to decide where to install. Maybe make some sort of ~/.textmate-cli config file?
0
+ desc "install NAME [SOURCE]", "install a bundle"
0
+ def install(bundle_name, remote_bundle_location_name=nil)
0
+ # TODO: Add an option to remove all other versions of the same bundle
0
FileUtils.mkdir_p install_bundles_path
0
- puts "Checking out #{name}..."
0
- res = %x[svn co #{svn_for(type)}/#{e_sh name}.tmbundle #{e_sh install_bundles_path}/#{e_sh name}.tmbundle]
0
+ puts "Checking out #{bundle_name}..."
0
+ # CHANGED: It's faster to just try and fail for each repo than to search them all first
0
+ remote_bundle_locations.each do |remote_name,location|
0
+ next unless remote_name.to_s.downcase.include? remote_bundle_location_name.to_s.downcase if remote_bundle_location_name
0
+ cmd = 'echo "git remotes not implemented yet"' if location[:scm]==:git
0
+ cmd = %[svn co #{e_sh location[:url]}/#{e_sh bundle_name}.tmbundle #{e_sh install_bundles_path}/#{e_sh bundle_name}.tmbundle 2>&1] if location[:scm]==:svn
0
+ puts cmd, res.gsub(/^/,' ') #if verbose # TODO: Implement a verbose mode to toggle showing all the gory details
0
+ installed=true and break if res =~ /Checked out revision|Initialized empty Git repository/
0
+ abort 'Not Installed' unless installed # TODO: Offer suggestions for alternate bundles with similar names. Maybe let them choose
0
puts "Reloading Bundles..."
0
desc "uninstall NAME", "uninstall a bundle"
0
+ def uninstall(
bundle_name)
0
puts "Removing bundle..."
0
# FIXME: Move deleted bundles to the trash instead of rm_rf-ing them?
0
# When moving to the trash, maybe move the bundle into a trash/disabled_bundles subfolder
0
# named as the bundles_path key. Just in case there are multiple versions of
0
# the same bundle in multiple bundle paths
0
- bundles_paths.each do |location,bundles_path|
0
- FileUtils.rm_rf("#{bundles_path}/#{name}.tmbundle")
0
+ local_bundle_paths.each do |name,bundles_path|
0
+ FileUtils.rm_rf("#{bundles_path}/#{bundle_name}.tmbundle")
0
puts "Reloading bundles..."
0
@@ -56,23 +75,22 @@ class TextmateInstaller < Thor
0
%x[osascript -e 'tell app "TextMate" to reload bundles']
0
- bundles = %x[svn list #{svn_for("bundles")}].map {|x| x.split(".")[0]}
0
- review = %x[svn list #{svn_for("review")}].map {|x| x.split(".")[0]}
0
- return "bundles" if bundles.include?(bundle)
0
- return "review" if review.include?(bundle)
0
- "http://macromates.com/svn/Bundles/trunk/Bundles"
0
- elsif type =~ /review/i
0
- "http://macromates.com/svn/Bundles/trunk/Review/Bundles"
0
+ def remote_bundle_locations
0
+ { :'Marcomates Trunk' => {:scm => :svn, :url => 'http://macromates.com/svn/Bundles/trunk/Bundles'},
+ :'Marcomates Review' => {:scm => :svn, :url => 'http://macromates.com/svn/Bundles/trunk/Review/Bundles'},
0
+ # TODO: Add Git support to remote_bundle_locations. Define some sort of standard way of listing git repos, checkout how rubygems does it
0
+ # :'Bunch of Git Bundles' => {:scm => :git, :url => 'git://NotImplemented'},
0
+ # TODO: Add GitHub support as a remote_bundle_location
0
+ # This will require fetching the html of the search page, scanning for urls and converting them to git urls
0
+ # :'GitHub' => {:scm => :github, :url => 'http://github.com/search?q=tmbundle'},
0
+ # TODO: Add some way to add more custom remotes
0
+ def
local_bundle_paths
0
{ :Application => '/Applications/TextMate.app/Contents/SharedSupport/Bundles',
0
:User => "#{ENV["HOME"]}/Library/Application Support/TextMate/Bundles",
0
:System => '/Library/Application Support/TextMate/Bundles',
0
@@ -83,7 +101,7 @@ class TextmateInstaller < Thor
0
def install_bundles_path
0
#TODO: Add some way for the user to configure where they'd prefer to install bundles
0
-
bundles_paths[:'User Pristine']
0
+
local_bundle_paths[:'User Pristine']
0
# Copied from http://macromates.com/svn/Bundles/trunk/Support/lib/escape.rb
0
@@ -94,4 +112,38 @@ class TextmateInstaller < Thor
0
+# TODO: create a "monument to personal cleverness" by class-izing everything?
0
+# def self.find_local(bundle_name)
0
+# def self.find_remote(bundle_name)
0
+# attr_reader :location
0
+# def initialize(name, location, scm)
0
+# # List all the installed versions, and where they're at
0
+# # TODO: dirty? method to show if there are any deltas
0
TextmateInstaller.start
Comments
maRComates?
(I would make a cheesy joke about Marco Polo, but, er…)
TYPO
Noooooooo!!!!!!
:’(
:P :D
I’ll have to remember that link. :D
(Oh, and yay for Safari’s “Go To Address in New Tab” text-selection context-menu)
Ugh. too many ”!” and textile thinks anything is an image :’(