lib/cloudstack-cli/base.rb in cloudstack-cli-0.3.1 vs lib/cloudstack-cli/base.rb in cloudstack-cli-0.3.2
- old
+ new
@@ -2,10 +2,12 @@
require "yaml"
module CloudstackCli
class Base < Thor
include Thor::Actions
+ include CloudstackCli::Helper
+
attr_reader :config
# catch control-c and exit
trap("SIGINT") {
puts " bye"
@@ -27,14 +29,18 @@
opts
)
end
def load_configuration(config_file = options[:config], env = options[:environment])
+ unless File.exists?(config_file)
+ say "Configuration file #{config_file} not found.", :red
+ say "Please run \'cs setup\' to create one."
+ exit 1
+ end
begin
config = YAML::load(IO.read(config_file))
rescue
error "Can't load configuration from file #{config_file}."
- error "To create a new configuration file run \"cs setup\"."
exit 1
end
if env
config = config[env]
unless config
\ No newline at end of file