Class: DoSnapshot::CLI

Inherits:
Thor
  • Object
show all
Includes:
Helpers
Defined in:
lib/do_snapshot/cli.rb

Overview

CLI is here

Instance Method Summary collapse

Methods included from Helpers

#logger, #mailer

Constructor Details

#initialize(*args) ⇒ CLI

Overriding Thor method for custom initialization



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/do_snapshot/cli.rb', line 23

def initialize(*args)
  super

  setup_config
  set_logger
  set_mailer

  # Check for keys via options
  %w( digital_ocean_access_token ).each do |key|
    ENV[key.upcase] = options[key] if options.include? key
  end
end

Instance Method Details

#snapObject



160
161
162
163
164
165
166
167
# File 'lib/do_snapshot/cli.rb', line 160

def snap
  command.snap
rescue DoSnapshot::NoTokenError, DoSnapshot::NoKeysError => e
  error_simple(e)
rescue => e
  command.fail_power_off(e) if [SnapshotCreateError, DropletShutdownError].include?(e.class)
  error_with_backtrace(e)
end

#versionObject



170
171
172
# File 'lib/do_snapshot/cli.rb', line 170

def version
  puts DoSnapshot::VERSION
end