inspec/bin/vulcano
Dominik Richter 360da9a7ba feature: configure ssh+winrm targets on CLI-runner
Signed-off-by: Dominik Richter <dominik.richter@gmail.com>
2015-08-12 14:19:44 -07:00

66 lines
2 KiB
Ruby
Executable file

#!/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
option :id, type: :string
def json(*paths)
require_relative '../lib/verify'
paths.each do |path|
Vulcano::Profiles.new.valid_folder? path unless options[:print]
vc = Vulcano::Profiles.new({ quiet: options[:print], id: options[:id] })
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
desc "check PATH", "check all tests in PATH"
def check(*paths)
require_relative '../lib/verify'
paths.each do |path|
puts "#{path}"
Vulcano::Profiles.new.valid_folder? path
puts
end
end
desc "exec PATHS", "run all test files"
option :id, type: :string
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
def exec(*files)
runner = Vulcano::Runner.new(options[:id], options)
files.each do |file|
runner.add_file(file)
end
end
end
VulcanoCLI.start(ARGV)