Sha256: 2ca67a5e5c5db6071cfa433cc9eb2edbe65c7410e0697749444972ecbd5182af

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

module PrChangelog
  # Used for the implementation of the exposed executable for this gem
  class CLI
    HELP_TEXT = <<~HELP
      Usage: pr_changelog [options] from_reference to_reference

      [Options]

        -h, --help\tShow this help
        --format FORMAT_NAME\t(default "plain"), options ("pretty", "plain")

      [Examples]

        Listing the changes for the last release (since the previous to the last one)

        $ pr_changelog
    HELP

    attr_reader :format, :from_reference, :to_reference

    def initialize(args)
      @format = 'pretty'
      if args.include?('--format')
        next_index = args.index('--format') + 1
        @format = args.fetch(next_index)
      end
      @from_reference, @to_reference = args.last(2)
    end

    def run
      changes = NotReleasedChanges.new(from_reference, to_reference)
      if format == 'pretty'
        puts changes.grouped_formatted_changelog
      else
        puts changes.formatted_changelog
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pr_changelog-0.1.1 lib/pr_changelog/cli.rb