lib/shelly/cli/main.rb in shelly-0.0.18 vs lib/shelly/cli/main.rb in shelly-0.0.19
- old
+ new
@@ -1,26 +1,26 @@
require "shelly"
require "thor/group"
-require "shelly/cli/users"
+require "shelly/cli/user"
module Shelly
module CLI
class Main < Thor
include Thor::Actions
include Helpers
- register(Users, "users", "users <command>", "Manages users using this app")
+ register(User, "user", "user <command>", "Manages users using this app")
check_unknown_options!
map %w(-v --version) => :version
desc "version", "Displays shelly version"
def version
say "shelly version #{Shelly::VERSION}"
end
desc "register [EMAIL]", "Registers new user account on Shelly Cloud"
def register(email = nil)
- user = User.new
+ user = Shelly::User.new
user.ssh_key_registered?
say "Registering with email: #{email}" if email
user.email = (email || ask_for_email)
user.password = ask_for_password
user.register
@@ -43,11 +43,11 @@
say_error "Use ssh-keygen to generate ssh key pair"
end
desc "login [EMAIL]", "Logins user to Shelly Cloud"
def login(email = nil)
- user = User.new(email || ask_for_email, ask_for_password(:with_confirmation => false))
+ user = Shelly::User.new(email || ask_for_email, ask_for_password(:with_confirmation => false))
user.login
say "Login successful"
say "Uploading your public SSH key"
user.upload_ssh_key
say "You have following applications available:", :green
@@ -68,14 +68,14 @@
end
method_option "code-name", :type => :string, :aliases => "-c",
:desc => "Unique code_name of your application"
method_option :databases, :type => :array, :aliases => "-d",
- :banner => "#{Shelly::App::DATABASE_KINDS.join(' ')}",
+ :banner => "#{Shelly::App::DATABASE_KINDS.join(', ')}",
:desc => "Array of databases of your choice"
method_option :domains, :type => :array,
- :banner => "CODE-NAME.shellyapp.com YOUR-DOMAIN.com",
+ :banner => "CODE-NAME.shellyapp.com, YOUR-DOMAIN.com",
:desc => "Array of your domains"
desc "add", "Adds new application to Shelly Cloud"
def add
say_error "Must be run inside your project git repository" unless App.inside_git_repository?
check_options(options)
@@ -108,11 +108,9 @@
# FIXME: move to helpers
no_tasks do
def check_options(options)
unless options.empty?
- options["domains"].map! {|domain| domain.gsub(",", "") } if options["domains"]
- options["databases"].map! {|kind| kind.gsub(",", "") } if options["databases"]
unless ["code-name", "databases", "domains"].all? do |option|
options.include?(option.to_s) && options[option.to_s] != option.to_s
end && valid_databases?(options["databases"])
say_error "Try 'shelly help add' for more information"
end