Skip to content

Commit

Permalink
Added option to create ~/.caprc file.
Browse files Browse the repository at this point in the history
    depify -c
  • Loading branch information
mbailey committed Mar 17, 2009
1 parent 5c74209 commit 0eca8b9
Showing 1 changed file with 33 additions and 27 deletions.
60 changes: 33 additions & 27 deletions bin/depify
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,6 @@

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}/, "")
Expand Down Expand Up @@ -116,6 +89,39 @@ def create_file(file, 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
Expand Down

0 comments on commit 0eca8b9

Please sign in to comment.