def run
require_site
deploy_configs = site.config.fetch(:deploy) do
raise Nanoc::Errors::GenericTrivial, "The site configuration has no deploy configuration."
end
if options[:list]
puts "Available deployment configurations:"
deploy_configs.keys.each do |name|
puts " #{name}"
end
return
end
target = options.fetch(:target, :default).to_sym
config = deploy_configs.fetch(target) do
raise Nanoc::Errors::GenericTrivial, "The site configuration has no deploy configuration for #{target}."
end
names = Nanoc::Extra::Deployer.all.keys
name = config.fetch(:kind) do
$stderr.puts "Warning: The specified deploy target does not have a kind attribute. Assuming rsync."
'rsync'
end
deployer_class = Nanoc::Extra::Deployer.named(name)
if deployer_class.nil?
raise Nanoc::Errors::GenericTrivial, "The specified deploy target has an unrecognised kind “#{name}” (expected one of #{names.join(', ')})."
end
deployer = deployer_class.new(
site.config[:output_dir],
config,
:dry_run => options['dry-run''dry-run'])
deployer.run
end