lib/shelly/cli/main.rb in shelly-0.0.52 vs lib/shelly/cli/main.rb in shelly-0.0.53
- old
+ new
@@ -71,24 +71,26 @@
method_option "code-name", :type => :string, :aliases => "-c",
:desc => "Unique code-name of your cloud"
method_option :databases, :type => :array, :aliases => "-d",
:banner => Shelly::App::DATABASE_KINDS.join(', '),
:desc => "List of databases of your choice"
- method_option :domains, :type => :array,
- :banner => "CODE-NAME.shellyapp.com, YOUR-DOMAIN.com",
- :desc => "List of your domains"
desc "add", "Add a new cloud"
def add
check_options(options)
@app = Shelly::App.new
@app.code_name = options["code-name"] || ask_for_code_name
@app.databases = options["databases"] || ask_for_databases
- @app.domains = options["domains"] || ["#{@app.code_name}.shellyapp.com"]
@app.create
- say "Adding remote production #{@app.git_url}", :green
- @app.add_git_remote
+ git_remote = @app.git_remote_exist?
+ if !git_remote or (git_remote and yes?("Git remote #{@app} exists, overwrite (yes/no): "))
+ say "Adding remote #{@app} #{@app.git_url}", :green
+ @app.add_git_remote
+ else
+ say "You have to manually add git remote:"
+ say "`git remote add NAME #{@app.git_url}`"
+ end
say "Creating Cloudfile", :green
@app.create_cloudfile
if @app.attributes["trial"]
say_new_line
@@ -98,17 +100,17 @@
url = "#{@app.shelly.shellyapp_url}/apps/#{@app.code_name}/billing/edit"
say url
end
info_adding_cloudfile_to_repository
- info_deploying_to_shellycloud
+ info_deploying_to_shellycloud(@app)
rescue Client::ValidationException => e
e.each_error { |error| say_error error, :with_exit => false }
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(',')} --domains=#{@app.domains.join(',')}"
+ say_error "shelly add --code-name=#{@app.code_name} --databases=#{@app.databases.join(',')}"
end
desc "list", "List available clouds"
def list
user = Shelly::User.new
@@ -313,11 +315,11 @@
end
end
def check_options(options)
unless options.empty?
- unless ["code-name", "databases", "domains"].all? do |option|
+ unless ["code-name", "databases"].all? do |option|
options.include?(option.to_s) && options[option.to_s] != option.to_s
end && valid_databases?(options["databases"])
# FIXME: ' to `
say_error "Try 'shelly help add' for more information"
end
@@ -347,12 +349,12 @@
end
end
end
def ask_for_code_name
- default_code_name = "#{Shelly::App.guess_code_name}-production"
- code_name = ask("Cloud code name (#{default_code_name} - default):")
+ default_code_name = Shelly::App.guess_code_name
+ code_name = ask("Cloud code name (#{Shelly::App.guess_code_name} - default):")
code_name.blank? ? default_code_name : code_name
end
def ask_for_databases
kinds = Shelly::App::DATABASE_KINDS
@@ -372,18 +374,18 @@
say "Project is now configured for use with Shell Cloud:", :green
say "You can review changes using", :green
say " git status"
end
- def info_deploying_to_shellycloud
+ def info_deploying_to_shellycloud(remote)
say_new_line
say "When you make sure all settings are correct please issue following commands:", :green
say " git add ."
say ' git commit -m "Application added to Shelly Cloud"'
say " git push"
say_new_line
- say "Deploy to production using:", :green
- say " git push production master"
+ say "Deploy to your cloud using:", :green
+ say " git push #{remote} master"
say_new_line
end
end
end
end