add aliases for target and backend

Signed-off-by: Dominik Richter <dominik.richter@gmail.com>
This commit is contained in:
Dominik Richter 2015-08-29 19:46:46 -07:00
parent 601abe2579
commit 04db46f116
4 changed files with 14 additions and 4 deletions

View file

@ -45,9 +45,9 @@ class VulcanoCLI < Thor
desc "exec PATHS", "run all test files"
option :id, type: :string,
desc: 'Attach a profile ID to all test results'
option :target, type: :string, default: nil,
option :target, aliases: :t, type: :string, default: nil,
desc: 'Simple targeting option using URIs, e.g. ssh://user:pass@host:port'
option :backend, type: :string, default: nil,
option :backend, aliases: :b, type: :string, default: nil,
desc: 'Choose a backend: exec (run locally), ssh, winrm.'
option :host, type: :string,
desc: 'Specify a remote host which is tested.'

View file

@ -7,14 +7,19 @@ module Vulcano
@registry ||= {}
end
def self.target_config( conf )
def self.target_config( config )
conf = config.dup
return conf if conf[:target].to_s.empty?
uri = URI::parse(conf[:target].to_s)
conf[:backend] = conf[:backend] || uri.scheme
conf[:host] = conf[:host] || uri.host
conf[:port] = conf[:port] || uri.port
conf[:user] = conf[:user] || uri.user
conf[:password] = conf[:password] || uri.password
# return the updated config
conf
end
end

View file

@ -9,7 +9,12 @@ module Vulcano::Backends
@conf = conf
@files = {}
type = @conf[:backend]
configure_shared_options
# configure the given backend, if we can handle it
# e.g. backend = exec ==> try to call configure_exec
# if we don't support it, error out
m = "configure_#{type}"
if self.respond_to?(m.to_sym)
self.send(m)

View file

@ -21,7 +21,7 @@ module Vulcano
def initialize(profile_id, conf)
@rules = []
@profile_id = profile_id
@conf = Vulcano::Backend.target_config(conf).dup
@conf = Vulcano::Backend.target_config(conf)
configure_output
configure_backend
end