Sha256: 702d5a28fd61902e9534748ca4718e38b12d6211ec13f44b143d35125f7b2026

Contents?: true

Size: 722 Bytes

Versions: 3

Compression:

Stored size: 722 Bytes

Contents

# frozen_string_literal: true

module PrChangelog
  class CLI
    # A simple wrapper over ARGV that is passed to the CLI class
    class Args
      def initialize(raw_args)
        @raw_args = raw_args
      end

      def include?(flag)
        raw_args.include?(flag)
      end

      def value_for(flag)
        return nil unless raw_args.index(flag)

        next_index = raw_args.index(flag) + 1
        value = raw_args.delete_at(next_index)
        raw_args.delete(flag)
        value
      end

      def include_flags?(flag, flag_variation)
        include?(flag) || include?(flag_variation)
      end

      def last(number)
        raw_args.last(number)
      end

      attr_reader :raw_args
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pr_changelog-0.4.1 lib/pr_changelog/cli/args.rb
pr_changelog-0.4.0 lib/pr_changelog/cli/args.rb
pr_changelog-0.3.0 lib/pr_changelog/cli/args.rb