Sha256: 9a63e1ae0335b60954fa226879b95baab6b04f99f71f5682216490b09da8f250

Contents?: true

Size: 702 Bytes

Versions: 4

Compression:

Stored size: 702 Bytes

Contents

require 'optparse'

module Sijka
  class SijkaParser
    def initialize(argv, stdin)
      @argv = argv
      @stdin = stdin
    end

    def parse_flags
      options = {}
      OptionParser.new do |opts|
        opts.banner = "Usage: sijka [name] [-h] [-f sijkafile] [-l]"
        opts.on("-l", "List available sijka files") do |sijkafile|
          options['list'] = true
        end
        opts.on("-f SIJKAFILE", "Specify a sijka file") do |sijkafile|
          options['sijkafile'] = sijkafile
        end
      end.parse!
      options
    end

    def parse_message
      if @argv.any?
        @argv.join(' ')
      else
        @stdin.tty? ? '' : @argv.read.chomp
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sijka-0.0.3.2 lib/sijka/parser.rb
sijka-0.0.3.1 lib/sijka/parser.rb
sijka-0.0.3 lib/sijka/parser.rb
sijka-0.0.2 lib/sijka/parser.rb