lib/shelly/cli/config.rb in shelly-0.1.27 vs lib/shelly/cli/config.rb in shelly-0.1.28

- old
+ new

@@ -1,19 +1,19 @@ require "shelly/cli/command" module Shelly module CLI class Config < Command - include Thor::Actions + namespace :config include Helpers before_hook :logged_in?, :only => [:list, :show, :create, :new, :edit, :update, :delete] class_option :cloud, :type => :string, :aliases => "-c", :desc => "Specify cloud" desc "list", "List configuration files" def list - app = multiple_clouds(options[:cloud], "list") + app = multiple_clouds(options[:cloud], "config list") configs = app.configs unless configs.empty? say "Configuration files for #{app}", :green user_configs = app.user_configs unless user_configs.empty? @@ -32,11 +32,11 @@ end end desc "show PATH", "View configuration file" def show(path) - app = multiple_clouds(options[:cloud], "show #{path}") + app = multiple_clouds(options[:cloud], "config show #{path}") config = app.config(path) say "Content of #{config["path"]}:", :green say config["content"] rescue Client::NotFoundException => e raise unless e.resource == :config @@ -60,11 +60,11 @@ map "update" => :edit desc "edit PATH", "Edit configuration file" def edit(path = nil) say_error "No configuration file specified" unless path - app = multiple_clouds(options[:cloud], "edit #{path}") + app = multiple_clouds(options[:cloud], "config edit #{path}") config = app.config(path) content = open_editor(config["path"], config["content"]) app.update_config(path, content) say "File '#{config["path"]}' updated.", :green say "To make changes to running application redeploy it using:" @@ -78,11 +78,11 @@ exit 1 end desc "delete PATH", "Delete configuration file" def delete(path) - app = multiple_clouds(options[:cloud], "delete #{path}") + app = multiple_clouds(options[:cloud], "config delete #{path}") answer = yes?("Are you sure you want to delete 'path' (yes/no): ") if answer app.delete_config(path) say "File '#{path}' deleted.", :green say "To make changes to running application redeploy it using:" @@ -103,20 +103,20 @@ end def open_editor(path, output = "") filename = "shelly-edit-" 0.upto(20) { filename += rand(9).to_s } - filename << File.extname(path) - filename = File.join(Dir.tmpdir, filename) - tf = File.open(filename, "w") + filename << ::File.extname(path) + filename = ::File.join(Dir.tmpdir, filename) + tf = ::File.open(filename, "w") tf.sync = true tf.puts output tf.close no_editor unless system("#{ENV['EDITOR']} #{tf.path}") - tf = File.open(filename, "r") + tf = ::File.open(filename, "r") output = tf.gets(nil) tf.close - File.unlink(filename) + ::File.unlink(filename) output end def no_editor say_error "Please set EDITOR environment variable"