lib/shelly/cli/main.rb in shelly-0.1.3 vs lib/shelly/cli/main.rb in shelly-0.1.4.pre
- old
+ new
@@ -110,10 +110,11 @@
say_new_line
say_error "Fix erros in the below command and type it again to create your cloud" , :with_exit => false
say_error "shelly add --code-name=#{app.code_name} --databases=#{app.databases.join(',')} --size=#{app.size}"
end
+ map "status" => :list
desc "list", "List available clouds"
def list
user = Shelly::User.new
apps = user.apps
unless apps.empty?
@@ -129,11 +130,10 @@
else
say "You have no clouds yet", :green
end
end
- map "status" => :list
map "ip" => :info
method_option :cloud, :type => :string, :aliases => "-c", :desc => "Specify cloud"
desc "info", "Show basic information about cloud"
def info
app = multiple_clouds(options[:cloud], "info")
@@ -280,39 +280,20 @@
user = Shelly::User.new
say "Your public SSH key has been removed from Shelly Cloud" if user.delete_ssh_key
say "You have been successfully logged out" if user.delete_credentials
end
- desc "execute CODE", "Run code on one of application servers"
- method_option :cloud, :type => :string, :aliases => "-c", :desc => "Specify cloud"
- long_desc %{
- Run code given in parameter on one of application servers.
- If a file name is given, run contents of that file."
- }
- def execute(file_name_or_code)
- app = multiple_clouds(options[:cloud], "execute #{file_name_or_code}")
-
- result = app.run(file_name_or_code)
- say result
-
- rescue Client::APIException => e
- if e[:message] == "App not running"
- say_error "Cloud #{app} is not running. Cannot run code."
- else
- raise
- end
- end
-
desc "rake TASK", "Run rake task"
method_option :cloud, :type => :string, :aliases => "-c", :desc => "Specify cloud"
def rake(task = nil)
task = rake_args.join(" ")
app = multiple_clouds(options[:cloud], "rake #{task}")
- result = app.rake(task)
- say result
- rescue Client::APIException => e
- raise unless e[:message] == "App not running"
+ app.rake(task)
+ rescue Client::NotFoundException => e
+ raise unless e.resource == :cloud
+ say_error "You have no access to '#{app}' cloud defined in Cloudfile"
+ rescue Client::ConflictException
say_error "Cloud #{app} is not running. Cannot run rake task."
end
desc "redeploy", "Redeploy application"
method_option :cloud, :type => :string, :aliases => "-c",
@@ -341,30 +322,39 @@
def open
app = multiple_clouds(options[:cloud], "open")
app.open
end
+ desc "execute CODE", "Run code on one of application servers"
+ method_option :cloud, :type => :string, :aliases => "-c", :desc => "Specify cloud"
+ def execute(file)
+ say_error "`shelly execute` is deprecated and will be removed in a future release of shelly gem, please use `shelly console`"
+ end
+
desc "console", "Open application console"
method_option :cloud, :type => :string, :aliases => "-c", :desc => "Specify cloud"
def console
app = multiple_clouds(options[:cloud], "console")
app.console
rescue Client::NotFoundException => e
raise unless e.resource == :cloud
say_error "You have no access to '#{app}' cloud defined in Cloudfile"
- rescue Client::APIException => e
+ rescue Client::ConflictException
say_error "Cloud #{app} is not running. Cannot run console."
end
desc "upload PATH", "Upload files to persisted data storage"
method_option :cloud, :type => :string, :aliases => "-c", :desc => "Specify cloud"
def upload(path)
+ unless command_exists?("rsync")
+ say_error "You need to install rsync in order to use `shelly upload`"
+ end
app = multiple_clouds(options[:cloud], "upload #{path}")
app.upload(path)
rescue Client::NotFoundException => e
raise unless e.resource == :cloud
say_error "You have no access to '#{app}' cloud defined in Cloudfile"
- rescue Client::APIException => e
+ rescue Client::ConflictException
say_error "Cloud #{app} is not running. Cannot upload files."
end
# FIXME: move to helpers
no_tasks do