7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/morsify/cli.rb', line 7
def self.parse(_args)
options = {}
optparse = OptionParser.new do |opts|
opts.banner = 'Usage: morsify [options]'
opts.on('-h', '--help', 'Prints this help') do
puts opts
exit
end
opts.on('-e TEXT', '--encode TEXT', 'Text to Morse') { |o| options[:encode] = o }
opts.on('-d MORSE_CODE', '--decode MORSE_CODE', 'Morse to Text') { |o| options[:decode] = o }
opts.on('-c', '--cyrillic') { |o| options[:ru] = o }
opts.on('-w MORSE_CODE', '--wave MORSE_CODE', 'Morse to WAV File') { |o| options[:wave] = o }
opts.on('-v', '--version') { |o| options[:version] = o }
end
begin
optparse.parse!
rescue OptionParser::InvalidOption, OptionParser::MissingArgument
puts 'Нераспознанный параметр!'
puts 'По команде «morsify -h» можно получить дополнительную информацию.'
exit
end
options
end
|