Sha256: 4d01c083ced8e63c0336e6a51fc26a83588392c43a754b729bd4193d34e5134e

Contents?: true

Size: 1.23 KB

Versions: 3

Compression:

Stored size: 1.23 KB

Contents

# frozen_string_literal: true

require "rubycritic/cli/options/argv"

module Skunk
  module Cli
    # :nodoc:
    class Options
      # Extends RubyCritic::Cli::Options::Argv to parse a subset of the
      # parameters accepted by RubyCritic
      class Argv < RubyCritic::Cli::Options::Argv
        # :reek:Attribute
        attr_accessor :output_filename

        def parse # rubocop:disable Metrics/MethodLength
          parser.new do |opts|
            opts.banner = "Usage: skunk [options] [paths]\n"

            opts.on("-b", "--branch BRANCH", "Set branch to compare") do |branch|
              self.base_branch = String(branch)
              set_current_branch
              self.mode = :compare_branches
            end

            opts.on("-o", "--out FILE", "Output report to file") do |filename|
              self.output_filename = filename
            end

            opts.on_tail("-v", "--version", "Show gem's version") do
              self.mode = :version
            end

            opts.on_tail("-h", "--help", "Show this message") do
              self.mode = :help
            end
          end.parse!(@argv)
        end

        def to_h
          super.merge(output_filename: output_filename)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
skunk-0.5.3 lib/skunk/cli/options/argv.rb
skunk-0.5.1 lib/skunk/cli/options/argv.rb
skunk-0.5.0 lib/skunk/cli/options/argv.rb