Sha256: f076ccda9340021dcfa4dc9f9e649fc12a6d4530361b7501cab177e4b02b938f

Contents?: true

Size: 1.12 KB

Versions: 4

Compression:

Stored size: 1.12 KB

Contents

require "optparse"
require_relative "version"

module Harmoniser
  class Parser
    def initialize(logger:)
      @logger = logger
      @options = {}
      @option_parser = OptionParser.new do |opts|
        opts.banner = "harmoniser [options]"
        opts.on "-e", "--environment ENV", "Set the application environment (defaults to inferred environment or 'production')" do |arg|
          @options[:environment] = arg
        end
        opts.on "-r", "--require [PATH|DIR]", "Specify a file to require or the location of the Rails application" do |arg|
          @options[:require] = arg
        end
        opts.on("-v", "--[no-]verbose", "Run verbosely (set log severity to 'debug' for detailed RabbitMQ interactions)") do |arg|
          @options[:verbose] = arg
        end
        opts.on "-V", "--version", "Print version and exit" do
          puts "Harmoniser #{Harmoniser::VERSION}"
          exit(0)
        end
        opts.on_tail "-h", "--help", "Show help" do
          puts @option_parser
          exit(0)
        end
      end
    end

    def call(argv = [])
      @option_parser.parse!(argv)
      @options
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
harmoniser-0.9.0 lib/harmoniser/parser.rb
harmoniser-0.8.1 lib/harmoniser/parser.rb
harmoniser-0.8.0 lib/harmoniser/parser.rb
harmoniser-0.7.0 lib/harmoniser/parser.rb