case insensitive flags

This commit is contained in:
Kelvin Sherlock 2016-02-08 22:07:53 -05:00
parent 556809470a
commit f1a86519d2
1 changed files with 15 additions and 0 deletions

View File

@ -143,6 +143,12 @@ argf_each {|filename, file|
help = data['help']
options = data['options']
case_insensitive = data['case_insensitive'] || false
# prevent warnings for unused vars.
options = options
help = help
case_insensitive = case_insensitive
# options is an array of items which may be hashes, strings, or numbers.
# normalize them.
@ -169,6 +175,12 @@ argf_each {|filename, file|
Option.new(opt)
}
if case_insensitive
options.each {|opt|
opt.char.downcase!
}
end
#data[options] = options
# check for help?
@ -281,6 +293,9 @@ int FlagsParse(int argc, char **argv)
% #
% options.each do |opt|
case '<%= escape_cstr(opt.char) %>':
% if case_insensitive && opt.char =~ /^[a-z]$/
case '<%= escape_cstr(opt.char.upcase) %>':
% end
% # check for an argument.
% flag_name = 'flags.' + opt.flag_name
% #