bin/depify in deprec-2.0.5 vs bin/depify in deprec-2.0.6

- old
+ new

@@ -1,36 +1,9 @@ #!/usr/bin/env ruby require 'optparse' -OptionParser.new do |opts| - opts.banner = "Usage: #{File.basename($0)} [path]" - - opts.on("-h", "--help", "Displays this help info") do - puts opts - exit 0 - end - - begin - opts.parse!(ARGV) - rescue OptionParser::ParseError => e - warn e.message - puts opts - exit 1 - end -end - -if ARGV.empty? - abort "Please specify the directory to depify, e.g. `#{File.basename($0)} .'" -elsif !File.exists?(ARGV.first) - abort "`#{ARGV.first}' does not exist." -elsif !File.directory?(ARGV.first) - abort "`#{ARGV.first}' is not a directory." -elsif ARGV.length > 1 - abort "Too many arguments; please specify only the directory to capify." -end - def unindent(string) indentation = string[/\A\s*/] string.strip.gsub(/^#{indentation}/, "") end @@ -112,9 +85,42 @@ warn "[skip] `#{file.downcase}' exists, which could conflict with `#{file}'" else puts "[add] writing `#{file}'" File.open(file, "w") { |f| f.write(content) } end +end + + +OptionParser.new do |opts| + opts.banner = "Usage: #{File.basename($0)} [path]" + + opts.on("-c", "Install ~/.caprc file") do + create_file(File.join(ENV['HOME'], '.caprc'), caprc) + exit 0 + end + + opts.on("-h", "--help", "Displays this help info") do + puts opts + exit 0 + end + + begin + opts.parse!(ARGV) + rescue OptionParser::ParseError => e + warn e.message + puts opts + exit 1 + end +end + +if ARGV.empty? + abort "Please specify the directory to depify, e.g. `#{File.basename($0)} .'" +elsif !File.exists?(ARGV.first) + abort "`#{ARGV.first}' does not exist." +elsif !File.directory?(ARGV.first) + abort "`#{ARGV.first}' is not a directory." +elsif ARGV.length > 1 + abort "Too many arguments; please specify only the directory to capify." end create_file(File.join(ENV['HOME'], '.caprc'), caprc) base = ARGV.shift