lib/shelly/cli/config.rb in shelly-0.1.9 vs lib/shelly/cli/config.rb in shelly-0.1.10

- old
+ new

@@ -28,30 +28,22 @@ print_configs(shelly_configs) end else say "Cloud #{cloud} has no configuration files" end - rescue Client::NotFoundException => e - raise unless e.resource == :cloud - say_error "You have no access to '#{app}' cloud defined in Cloudfile" end desc "show PATH", "View configuration file" def show(path) app = multiple_clouds(options[:cloud], "show #{path}") config = app.config(path) say "Content of #{config["path"]}:", :green say config["content"] rescue Client::NotFoundException => e - case e.resource - when :cloud - say_error "You have no access to '#{app}' cloud defined in Cloudfile" - when :config - say_error "Config '#{path}' not found", :with_exit => false - say_error "You can list available config files with `shelly config list --cloud #{app}`" - else raise - end + raise unless e.resource == :config + say_error "Config '#{path}' not found", :with_exit => false + say_error "You can list available config files with `shelly config list --cloud #{app}`" end map "new" => :create desc "create PATH", "Create configuration file" def create(path) @@ -59,13 +51,10 @@ app = multiple_clouds(options[:cloud], "create #{path}") app.create_config(path, output) say "File '#{path}' created.", :green say "To make changes to running application redeploy it using:" say "`shelly redeploy --cloud #{app}`" - rescue Client::NotFoundException => e - raise unless e.resource == :cloud - say_error "You have no access to '#{app}' cloud defined in Cloudfile" rescue Client::ValidationException => e e.each_error { |error| say_error error, :with_exit => false } exit 1 end @@ -79,18 +68,13 @@ app.update_config(path, content) say "File '#{config["path"]}' updated.", :green say "To make changes to running application redeploy it using:" say "`shelly redeploy --cloud #{app}`" rescue Client::NotFoundException => e - case e.resource - when :cloud - say_error "You have no access to '#{app}' cloud defined in Cloudfile" - when :config - say_error "Config '#{path}' not found", :with_exit => false - say_error "You can list available config files with `shelly config list --cloud #{app}`" - else raise - end + raise unless e.resource == :config + say_error "Config '#{path}' not found", :with_exit => false + say_error "You can list available config files with `shelly config list --cloud #{app}`" rescue Client::ValidationException => e e.each_error { |error| say_error error, :with_exit => false } exit 1 end @@ -106,18 +90,13 @@ say "`shelly redeploy --cloud #{app}`" else say "File not deleted" end rescue Client::NotFoundException => e - case e.resource - when :cloud - say_error "You have no access to '#{app}' cloud defined in Cloudfile" - when :config - say_error "Config '#{path}' not found", :with_exit => false - say_error "You can list available config files with `shelly config list --cloud #{app}`" - else raise - end + raise unless e.resource == :config + say_error "Config '#{path}' not found", :with_exit => false + say_error "You can list available config files with `shelly config list --cloud #{app}`" end no_tasks do def print_configs(configs) print_table(configs.map { |config| @@ -143,9 +122,8 @@ def no_editor say_error "Please set EDITOR environment variable" end end - end end end