86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
# File 'lib/license/compatibility.rb', line 86
def self.parse(args)
options = {}
option_parser = OptionParser.new do |opts|
opts.banner = "#{USAGE}\n\n"
opts.banner += "Arguments:\n"
opts.banner += " List of licenses or list of package:license couples (separated by ':').\n"
opts.banner += " Example: 'MIT' 'GPL-3.0' or 'my_package:ISC' 'other_pkg:BSD-2-Clause'.\n"
opts.banner += " Mixing the two formats is not allowed.\n"
opts.banner += " Additional args after a --read option are accepted.\n\n"
opts.banner += "Options:"
opts.on('-l', '--list', 'Print the list of supported licenses.') do
options[:list] = License::Compatibility.license_data
return options
end
opts.on('-r', '--read FILE', 'Read arguments from file.') do |file|
unless File.exist?(file)
raise Errno::ENOENT, "#{file}"
end
unless File.file?(file)
raise ArgumentError, "#{file} is a directory, you must specify a regular file"
end
options[:read] = file
end
opts.on('-v', '--version', "Show the program version (#{License::Compatibility::VERSION}).") do
options[:version] = "license-compatibility v#{License::Compatibility::VERSION}"
return options
end
opts.on('-h', '--help', 'Print this help.') do
options[:help] = opts.to_s
return options
end
end
option_parser.parse!(args)
return options
end
|