Class: Ec2ssh::CLI
- Inherits:
-
Thor
- Object
- Thor
- Ec2ssh::CLI
- Defined in:
- lib/ec2ssh/cli.rb
Instance Method Summary collapse
- #init ⇒ Object
- #migrate ⇒ Object
- #remove ⇒ Object
- #shellcomp(_ = false) ⇒ Object
- #update ⇒ Object
- #version ⇒ Object
Instance Method Details
#init ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/ec2ssh/cli.rb', line 14 def init check_dotfile_version command = make_command :init command.run rescue MarkAlreadyExists red "Marker already exists in #{command.ssh_config_path}" end |
#migrate ⇒ Object
49 50 51 52 |
# File 'lib/ec2ssh/cli.rb', line 49 def migrate command = make_command :migrate command.run end |
#remove ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/ec2ssh/cli.rb', line 38 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 |
#shellcomp(_ = false) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/ec2ssh/cli.rb', line 55 def shellcomp(_ = false) if args.include?("-") print_rc = true else print_rc = false end # print instructions for automatically enabling shell completion unless print_rc puts "# Enable ec2ssh completion by adding\n# the following to .bash_profile/.zshrc\n\ntype ec2ssh >/dev/null 2>&1 && eval \"$(ec2ssh shellcomp -)\"\n\n" exit(false) end # print shell script for enabling shell completion zsh_comp_file = File.("../../../zsh/_ec2ssh", __FILE__) bash_comp_file = File.("../../../bash/ec2ssh.bash", __FILE__) puts "if [ -n \"${BASH_VERSION:-}\" ]; then\nsource \#{bash_comp_file}\nelif [ -n \"${ZSH_VERSION:-}\" ]; then\nsource \#{zsh_comp_file}\nfi\n" end |
#update ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/ec2ssh/cli.rb', line 23 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 red "Set aws keys at #{command.dotfile_path}" rescue MarkNotFound red "Marker not found in #{command.ssh_config_path}" red "Execute '#{$0} init' first!" end |
#version ⇒ Object
87 88 89 90 |
# File 'lib/ec2ssh/cli.rb', line 87 def version require 'ec2ssh/version' puts "ec2ssh #{Ec2ssh::VERSION}" end |