lib/ec2ssh/cli.rb in ec2ssh-3.1.1 vs lib/ec2ssh/cli.rb in ec2ssh-4.0.0
- old
+ new
@@ -1,30 +1,27 @@
require 'thor'
require 'highline'
require 'ec2ssh/ssh_config'
require 'ec2ssh/exceptions'
-require 'ec2ssh/migrator'
module Ec2ssh
class CLI < Thor
class_option :path, banner: "/path/to/ssh_config"
class_option :dotfile, banner: '$HOME/.ec2ssh', default: "#{ENV['HOME']}/.ec2ssh"
class_option :verbose, banner: 'enable debug log', type: 'boolean'
desc 'init', 'Add ec2ssh mark to ssh_config'
def init
- check_dotfile_version
command = make_command :init
command.run
rescue MarkAlreadyExists
red "Marker already exists in #{command.ssh_config_path}"
end
desc 'update', 'Update ec2 hosts list in ssh_config'
def update
check_dotfile_existence
- check_dotfile_version
set_aws_logging
command = make_command :update
command.run
green "Updated #{command.ssh_config_path}"
rescue AwsKeyNotFound
@@ -35,24 +32,17 @@
end
desc 'remove', 'Remove ec2ssh mark from ssh_config'
def remove
check_dotfile_existence
- check_dotfile_version
command = make_command :remove
command.run
green "Removed mark from #{command.ssh_config_path}"
rescue MarkNotFound
red "Marker not found in #{command.ssh_config_path}"
end
- desc 'migrate', 'Migrate dotfile from old versions'
- def migrate
- command = make_command :migrate
- command.run
- end
-
desc 'shellcomp [-]', 'Initialize shell completion for bash/zsh'
def shellcomp(_ = false)
if args.include?("-")
print_rc = true
else
@@ -88,20 +78,10 @@
require 'ec2ssh/version'
puts "ec2ssh #{Ec2ssh::VERSION}"
end
no_tasks do
- def check_dotfile_version
- return unless File.exist?(options.dotfile)
- migrator = Migrator.new options.dotfile
- if migrator.check_version < '3'
- red "#{options.dotfile} is old style."
- red "Try '#{$0} migrate' to migrate to version 3"
- abort
- end
- end
-
def check_dotfile_existence
unless File.exist?(options.dotfile)
red "#{options.dotfile} doesn't exist."
red "Try '#{$0} init' to generate it or specify the path with --dotfile option"
abort
@@ -118,10 +98,10 @@
if options.verbose
require 'logger'
require 'aws-sdk'
logger = ::Logger.new($stdout)
logger.level = ::Logger::DEBUG
- ::AWS.config logger: logger
+ ::Aws.config.update logger: logger
end
end
def hl
@hl ||= ::HighLine.new