lib/sconb.rb in sconb-0.0.1 vs lib/sconb.rb in sconb-0.0.2
- old
+ new
@@ -41,17 +41,17 @@
puts JSON.pretty_generate configs
end
desc "restore < dump.json > .ssh/config", "Restore .ssh/config from JSON"
def restore()
- ssh_config = ''
json = ''
while str = $stdin.gets
json << str
end
configs = JSON.parse(json)
configs.each do |host, config|
+ ssh_config << "\n"
ssh_config << 'Host ' + host + "\n"
config.each do |key, value|
next if key.downcase == 'host' || key.downcase == 'identityfilecontent'
if key.downcase == 'identityfile'
value.each_with_index do |keyfile,i|
@@ -59,10 +59,9 @@
end
else
ssh_config << ' ' + key + ' ' + value + "\n"
end
end
- ssh_config << "\n"
end
puts ssh_config
end
method_option :force, :type => :boolean, :aliases => '-f', :default => false, :banner => 'force generate'