C
Chris Patti
How can I make my code print the usage even if zero options are given?
I had *thought* opts.on_tail would do this, but it doesn't seem to be
working. The usage prints properly if I use -h though:
---
require 'optparse'
options = {}
OptionParser.new do |opts|
opts.banner = "Usage: #$0 [options] [terms]"
opts.on("-a", "--automatic", "Use current Git repo to determine
current and next release branch and tag names") do |a|
options[:automatic] = a
end
opts.on("-n", "--next-branch [nextbranch]", "The branch you want
this script to create.") do |n|
options[:nextbranch] = n
end
opts.on("-t", "--tag [tag]", "The tag you want the new branch
created from.") do |t|
options[:tag] = t
end
opts.on_tail("-h", "--help", "Show this help message.") do
puts opts
exit
end
end.parse!
I had *thought* opts.on_tail would do this, but it doesn't seem to be
working. The usage prints properly if I use -h though:
---
require 'optparse'
options = {}
OptionParser.new do |opts|
opts.banner = "Usage: #$0 [options] [terms]"
opts.on("-a", "--automatic", "Use current Git repo to determine
current and next release branch and tag names") do |a|
options[:automatic] = a
end
opts.on("-n", "--next-branch [nextbranch]", "The branch you want
this script to create.") do |n|
options[:nextbranch] = n
end
opts.on("-t", "--tag [tag]", "The tag you want the new branch
created from.") do |t|
options[:tag] = t
end
opts.on_tail("-h", "--help", "Show this help message.") do
puts opts
exit
end
end.parse!