bin/clouddns in clouddns-0.0.2 vs bin/clouddns in clouddns-0.0.3
- old
+ new
@@ -7,14 +7,20 @@
options = {
:fog => {},
:force => false
}
-OptionParser.new do |opts|
- opts.banner = "Usage: #{$0} [OPTIONS] [ACTION] FILES"
+option_parser = OptionParser.new do |opts|
+ opts.banner = [
+ "Usage: #{$0} [OPTIONS] print FILES # Pretty print contents of FILES",
+ " #{$0} [OPTIONS] migrate FILES # Update DNS servers",
+ " #{$0} [OPTIONS] zonefile FILES # Print FILES as zone files",
+ "",
+ ""
+ ].join("\n")
- opts.on('-p', '--provider provider', "Override DNS provider (AWS, Zerigo, etc)") do |provider|
+ opts.on('-p', '--provider provider', "Override DNS provider (AWS, bluebox, dnsimple, dnsmadeeasy, linode, slicehost, zerigo)") do |provider|
options[:fog][:provider] = provider
end
opts.on('-f', '--force', 'Assume yes to all questions') do
options[:force] = true
@@ -27,16 +33,29 @@
opts.on_tail("-h", "--help", "Show this message") do
puts opts
exit
end
-end.parse!
+end
+option_parser.parse!
+
action = ARGV.slice!(0)
files = ARGV
-raise "No action specified" unless action
-raise "No files specified" if files.empty?
+if !action
+ error = "No action specified"
+elsif files.empty?
+ error = "No files specified"
+else
+ error = nil
+end
+
+if error
+ puts error
+ puts option_parser
+ exit 1
+end
action = Clouddns::Actions.by_name(action)
zones = files.map do |file|
dsl = Clouddns::DSL.parse_file(file)