lib/ec2ssh/cli.rb in ec2ssh-2.0.0 vs lib/ec2ssh/cli.rb in ec2ssh-2.0.1

- old
+ new

@@ -16,11 +16,11 @@ red "Marker already exists on #{config_path}" else config.append_mark! green "Added mark to #{config_path}" end - dotfile = Dotfile.update_or_create(options.dotfile, 'path' => options.path) + dotfile = Dotfile.update_or_create(options.dotfile, 'path' => config_path) yellow "Please check and edit #{options.dotfile} before run `ec2ssh update`" end desc "update", "Update ec2 hosts list in ssh_config" method_option :aws_key, :banner => 'aws key name', :default => 'default' @@ -61,14 +61,20 @@ def hosts @hosts ||= Hosts.new(dotfile, options.aws_key).all end def dotfile - @dotfile ||= Dotfile.load(options.dotfile) + @dotfile ||= begin + if File.exist?(options.dotfile) + Dotfile.load(options.dotfile) + else + Dotfile.new + end + end end def config_path - options.path || dotfile['path'] || "#{$ENV['HOME']}/.ssh/config" + options.path || dotfile['path'] || "#{ENV['HOME']}/.ssh/config" end [:red,:green,:yellow].each do |col| define_method(col) do |str| puts hl.color(str, col)