2015-06-07 19:41:54 +00:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
# Copyright 2015 Dominik Richter. All rights reserved.
|
|
|
|
|
|
|
|
require 'thor'
|
|
|
|
require 'json'
|
|
|
|
require_relative '../lib/vulcano'
|
|
|
|
|
|
|
|
class VulcanoCLI < Thor
|
|
|
|
|
|
|
|
desc "json PATH", "read all tests in PATH and generate a JSON-profile"
|
|
|
|
option :output, aliases: :o, type: :string
|
|
|
|
option :print, aliases: :p, type: :boolean
|
2015-06-25 15:45:46 +00:00
|
|
|
option :id, type: :string
|
2015-06-07 19:41:54 +00:00
|
|
|
def json(*paths)
|
2015-08-12 19:03:41 +00:00
|
|
|
require_relative '../lib/verify'
|
2015-06-07 19:41:54 +00:00
|
|
|
paths.each do |path|
|
2015-06-10 15:54:35 +00:00
|
|
|
Vulcano::Profiles.new.valid_folder? path unless options[:print]
|
2015-06-25 15:45:46 +00:00
|
|
|
vc = Vulcano::Profiles.new({ quiet: options[:print], id: options[:id] })
|
2015-06-07 19:41:54 +00:00
|
|
|
vc.add_folder(path)
|
|
|
|
if options[:print]
|
|
|
|
puts JSON.pretty_generate( vc.profiles )
|
|
|
|
else
|
|
|
|
dst = options[:output] || File.join( path, '.vulcano.json' )
|
|
|
|
if File::exist? dst
|
|
|
|
puts "----> updating #{dst}"
|
|
|
|
else
|
|
|
|
puts "----> creating #{dst}"
|
|
|
|
end
|
|
|
|
fdst = File::expand_path(dst)
|
|
|
|
File::write(fdst, JSON.dump(vc.profiles))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-06-10 15:03:12 +00:00
|
|
|
desc "check PATH", "check all tests in PATH"
|
|
|
|
def check(*paths)
|
2015-08-12 19:03:41 +00:00
|
|
|
require_relative '../lib/verify'
|
2015-06-10 15:03:12 +00:00
|
|
|
paths.each do |path|
|
|
|
|
puts "#{path}"
|
|
|
|
Vulcano::Profiles.new.valid_folder? path
|
|
|
|
puts
|
|
|
|
end
|
|
|
|
end
|
2015-06-07 19:41:54 +00:00
|
|
|
|
2015-08-12 19:03:41 +00:00
|
|
|
desc "exec PATHS", "run all test files"
|
|
|
|
option :id, type: :string
|
2015-08-12 21:19:44 +00:00
|
|
|
option :backend, type: :string, default: 'exec'
|
|
|
|
option :host, type: :string
|
|
|
|
option :port, type: :numeric
|
|
|
|
option :user, type: :string, default: 'root'
|
|
|
|
option :password, type: :string, default: nil
|
|
|
|
option :key_file, type: :string, default: nil
|
|
|
|
option :disable_sudo, type: :boolean, default: false
|
|
|
|
option :sudo_password, type: :string, default: nil
|
|
|
|
option :sudo_options, type: :string, default: ''
|
|
|
|
option :winrm_self_signed, type: :boolean, default: false
|
|
|
|
option :winrm_ssl, type: :boolean, default: false
|
2015-08-12 19:03:41 +00:00
|
|
|
def exec(*files)
|
2015-08-12 21:19:44 +00:00
|
|
|
runner = Vulcano::Runner.new(options[:id], options)
|
2015-08-12 19:03:41 +00:00
|
|
|
files.each do |file|
|
|
|
|
runner.add_file(file)
|
|
|
|
end
|
2015-08-12 22:16:50 +00:00
|
|
|
runner.run
|
2015-08-12 19:03:41 +00:00
|
|
|
end
|
|
|
|
|
2015-06-07 19:41:54 +00:00
|
|
|
end
|
|
|
|
VulcanoCLI.start(ARGV)
|