Class: Vmreverter::CLI
- Inherits:
-
Object
- Object
- Vmreverter::CLI
- Defined in:
- lib/vmreverter/cli.rb
Instance Method Summary collapse
- #execute! ⇒ Object
-
#initialize ⇒ CLI
constructor
A new instance of CLI.
Constructor Details
#initialize ⇒ CLI
Returns a new instance of CLI.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/vmreverter/cli.rb', line 3 def initialize = Vmreverter::Options.parse_args @logger = Vmreverter::Logger.new() if [:lockfile] if Pathname.new([:lockfile]).exist? report_and_raise(@logger, ArgumentError.new("Specified lockfile path '#{@options[:lockfile]}' is locked."), "Lockfile is locked") else FileUtils.touch([:lockfile]) end end if not [:config] report_and_raise(@logger, ArgumentError.new("Missing config, specify one (-c or --config)!"), "CLI: initialize") end @logger.debug("Options") .each do |opt, val| if val and val != [] @logger.debug("\t#{opt.to_s}:") if val.kind_of?(Array) val.each do |v| @logger.debug("\t\t#{v.to_s}") end else @logger.debug("\t\t#{val.to_s}") end end end Vmreverter::Configuration.build(, @logger) @config = Vmreverter::Configuration.instance end |
Instance Method Details
#execute! ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/vmreverter/cli.rb', line 39 def execute! begin trap(:INT) do @logger.warn "Interrupt received; exiting..." FileUtils.rm [:lockfile], :force => true if [:lockfile] exit(1) end Vmreverter::VMManager.execute!(@config) end #trap end |