vmc-ng/lib/vmc/cli.rb in vmc-0.4.0.beta.93 vs vmc-ng/lib/vmc/cli.rb in vmc-0.4.0.beta.94

- old
+ new

@@ -1,13 +1,12 @@ require "yaml" require "socket" require "net/http" require "multi_json" +require "fileutils" require "mothership" -require "mothership/pretty" -require "mothership/progress" require "cfoundry" require "vmc/constants" require "vmc/errors" @@ -21,12 +20,10 @@ module VMC class CLI < Mothership include VMC::Interactive include VMC::Spacing - include Mothership::Pretty - include Mothership::Progress option :help, :alias => "-h", :type => :boolean, :desc => "Show command usage & instructions" option :proxy, :alias => "-u", :value => :email, @@ -146,11 +143,15 @@ def log_error(e) msg = e.class.name msg << ": #{e}" unless e.to_s.empty? - File.open(File.expand_path(VMC::CRASH_FILE), "w") do |f| + crash_file = File.expand_path(VMC::CRASH_FILE) + + FileUtils.mkdir_p(File.dirname(crash_file)) + + File.open(crash_file, "w") do |f| f.puts "Time of crash:" f.puts " #{Time.now}" f.puts "" f.puts msg f.puts "" @@ -258,11 +259,11 @@ paths.each do |p| exp = File.expand_path(p) return exp if File.exist? exp end - paths.first + File.expand_path(paths.first) end def client_target File.read(target_file).chomp end @@ -394,24 +395,24 @@ private def find_by_name(what) proc { |name, choices, *_| choices.find { |c| c.name == name } || - fail("Unknown #{what} '#{name}'") + fail("Unknown #{what} '#{name}'.") } end def by_name(what, obj = what) proc { |name, *_| client.send(:"#{obj}_by_name", name) || - fail("Unknown #{what} '#{name}'") + fail("Unknown #{what} '#{name}'.") } end def find_by_name_insensitive(what) proc { |name, choices| choices.find { |c| c.name.upcase == name.upcase } || - fail("Unknown #{what} '#{name}'") + fail("Unknown #{what} '#{name}'.") } end end end end