Method: EdifactConverter::CommandLineParser.parser

Defined in:
lib/edifact_converter/command_line_parser.rb

.parserObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/edifact_converter/command_line_parser.rb', line 14

def parser
  @parser ||= begin
    OptionParser.new do|opts|
      opts.banner = "Usage: #{$COMMAND_NAME} [options] file"
      opts.on( '-x', '--xml', 'Convert from Edifact to XML' ) do
        options[:source] = :edifact
      end
      opts.on( '-e', '--edi', 'Convert from XML to Edifact' ) do
        options[:source] = :xml
      end
      opts.on( '-1', '--xml11', 'Only convert to XML 1-1') do
        options[:xml11] = true
      end
      opts.on( '-f', '--format', 'Format edifact output with newlines') do
        options[:format] = true
      end
      opts.on( '--html', 'Only convert to XML 1-1') do
        options[:html] = true
      end
      opts.on( '-l', '--logfile FILE', 'Write log to FILE' ) do |file|
        options[:logfile] = file
      end
      opts.on( '-o', '--output FILE', 'Write output to FILE' ) do |file|
        options[:to_file] = file
      end
      opts.on( '-v', '--version', "Prints version of #{$COMMAND_NAME}") do
        puts "#{$COMMAND_NAME} version #{VERSION}"
        exit
      end
      opts.on( '-h', '--help', 'Display this screen' ) do
        puts opts
        exit
      end
    end
  end

end