Class: Factorix::CLI::Commands::MOD::Changelog::Extract

Inherits:
Base
  • Object
show all
Defined in:
lib/factorix/cli/commands/mod/changelog/extract.rb

Overview

Extract a specific version’s changelog section

Instance Method Summary collapse

Methods inherited from Base

backup_support!, confirmable!, inherited, require_game_stopped!

Instance Method Details

#call(version:, json: false, changelog: "changelog.txt") ⇒ void

This method returns an undefined value.

Parameters:

  • version (String)

    version string (X.Y.Z or Unreleased)

  • json (Boolean) (defaults to: false)

    output in JSON format

  • changelog (String) (defaults to: "changelog.txt")

    path to changelog file



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/factorix/cli/commands/mod/changelog/extract.rb', line 22

def call(version:, json: false, changelog: "changelog.txt", **)
  target_version = version.casecmp("unreleased").zero? ? Factorix::Changelog::UNRELEASED : MODVersion.from_string(version)
  log = Factorix::Changelog.load(Pathname(changelog))
  section = log.find_section(target_version)

  if json
    out.puts JSON.pretty_generate(version: section.version.to_s, date: section.date, entries: section.categories)
  else
    out.puts log.format_section(section)
  end
end