factorix 0.9.0 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 970e619a2c58b6ee5c7502adc6803469accf6ee618e41e580df5f950a8b2ed15
4
- data.tar.gz: 6651e0dea495831ede26d577410722d5ea08542c6ee2516772c413ddec1b7b55
3
+ metadata.gz: 5212e69bd41c45ceffb0fd42e889868b706b0481e6a07567c98b2cce439bb5fc
4
+ data.tar.gz: e2386ba4154617497efbeddea3537b58eb164dd5af66e963c325d06626536895
5
5
  SHA512:
6
- metadata.gz: 6d10a143153a82c1d2b969d928ce85dd22c8c9bf95c793fe27e3287cc5f7408a00fcec47d839295d40390655667a3b1b6e1ab8e76947c9ce98eec8455f87438f
7
- data.tar.gz: 2feeb57d5fc6835ee674f3c024b7ef5a4710e3b4f496dc7ada5ecc76add61e1b0fc3dcc3c7e95aea2ae57d131b28d124da04c83bb7ca1c04869067cac251e4c7
6
+ metadata.gz: 62ece69fa0e7028367dff967cfb6e5d93ba4c5413be84b9a38cd13466687202a9417b57c09b4b137ca26e149a556b1063d086342747ae95590ace736c492efa6
7
+ data.tar.gz: 8687814b5cb8f3af5e695db5765117c113de95d09fa361a87e04222f106e30abb935be426eb775751410d0181ee73c9171af9380fea5358d2ae936e9c12ec267
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.9.1] - 2026-02-20
4
+
5
+ ### Added
6
+
7
+ - Add `mod changelog extract` command to extract a specific version's changelog section
8
+
3
9
  ## [0.9.0] - 2026-02-20
4
10
 
5
11
  ### Added
@@ -172,7 +172,7 @@ _factorix() {
172
172
  ;;
173
173
  changelog)
174
174
  if [[ $cword -eq 3 ]]; then
175
- COMPREPLY=($(compgen -W "add check release" -- "$cur"))
175
+ COMPREPLY=($(compgen -W "add check extract release" -- "$cur"))
176
176
  else
177
177
  case "${words[3]}" in
178
178
  add)
@@ -194,6 +194,15 @@ _factorix() {
194
194
  COMPREPLY=($(compgen -W "$global_opts --release --changelog --info-json" -- "$cur"))
195
195
  fi
196
196
  ;;
197
+ extract)
198
+ if [[ "$prev" == "--changelog" ]]; then
199
+ COMPREPLY=($(compgen -f -- "$cur"))
200
+ elif [[ "$prev" == "--version" ]]; then
201
+ COMPREPLY=($(compgen -W "Unreleased" -- "$cur"))
202
+ elif [[ "$cur" == -* ]]; then
203
+ COMPREPLY=($(compgen -W "$global_opts --version --json --changelog" -- "$cur"))
204
+ fi
205
+ ;;
197
206
  release)
198
207
  if [[ "$prev" == "--changelog" ]] || [[ "$prev" == "--info-json" ]]; then
199
208
  COMPREPLY=($(compgen -f -- "$cur"))
@@ -233,6 +233,7 @@ complete -c factorix -n "__factorix_using_subcommand mod sync" -ra '(__fish_comp
233
233
  # mod changelog subcommands
234
234
  complete -c factorix -n "__factorix_using_subcommand mod changelog" -a add -d 'Add an entry to MOD changelog'
235
235
  complete -c factorix -n "__factorix_using_subcommand mod changelog" -a check -d 'Validate MOD changelog structure'
236
+ complete -c factorix -n "__factorix_using_subcommand mod changelog" -a extract -d 'Extract a changelog section for a specific version'
236
237
  complete -c factorix -n "__factorix_using_subcommand mod changelog" -a release -d 'Release Unreleased changelog section with a version'
237
238
 
238
239
  # mod changelog add options
@@ -240,6 +241,11 @@ complete -c factorix -n "__factorix_using_sub_subcommand mod changelog add" -l v
240
241
  complete -c factorix -n "__factorix_using_sub_subcommand mod changelog add" -l category -d 'Category name' -xa "'Major Features' Features 'Minor Features' Graphics Sounds Optimizations Balancing 'Combat Balancing' 'Circuit Network' Changes Bugfixes Modding Scripting Gui Control Translation Debug 'Ease of use' Info Locale Compatibility"
241
242
  complete -c factorix -n "__factorix_using_sub_subcommand mod changelog add" -l changelog -d 'Path to changelog file' -rF
242
243
 
244
+ # mod changelog extract options
245
+ complete -c factorix -n "__factorix_using_sub_subcommand mod changelog extract" -l version -d 'Version (X.Y.Z or Unreleased)' -ra 'Unreleased'
246
+ complete -c factorix -n "__factorix_using_sub_subcommand mod changelog extract" -l json -d 'Output in JSON format'
247
+ complete -c factorix -n "__factorix_using_sub_subcommand mod changelog extract" -l changelog -d 'Path to changelog file' -rF
248
+
243
249
  # mod changelog check options
244
250
  complete -c factorix -n "__factorix_using_sub_subcommand mod changelog check" -l release -d 'Disallow Unreleased section'
245
251
  complete -c factorix -n "__factorix_using_sub_subcommand mod changelog check" -l changelog -d 'Path to changelog file' -rF
@@ -293,6 +293,7 @@ _factorix_mod_changelog() {
293
293
  subcommands=(
294
294
  'add:Add an entry to MOD changelog'
295
295
  'check:Validate MOD changelog structure'
296
+ 'extract:Extract a changelog section for a specific version'
296
297
  'release:Release Unreleased changelog section with a version'
297
298
  )
298
299
  _describe -t subcommands 'changelog subcommand' subcommands
@@ -314,6 +315,13 @@ _factorix_mod_changelog() {
314
315
  '--changelog[Path to changelog file]:changelog file:_files' \
315
316
  '--info-json[Path to info.json file]:info.json file:_files'
316
317
  ;;
318
+ extract)
319
+ _arguments \
320
+ $global_opts \
321
+ '--version[Version (X.Y.Z or Unreleased)]:version:(Unreleased)' \
322
+ '--json[Output in JSON format]' \
323
+ '--changelog[Path to changelog file]:changelog file:_files'
324
+ ;;
317
325
  release)
318
326
  _arguments \
319
327
  $global_opts \
@@ -89,21 +89,24 @@ module Factorix
89
89
  #
90
90
  # @return [String]
91
91
  def to_s
92
- @sections.map {|section| format_section(section) }.join("\n") + "\n"
92
+ @sections.map {|section| "#{SEPARATOR}\n#{format_section(section)}" }.join("\n") + "\n"
93
93
  end
94
94
 
95
- private def find_or_create_section(version)
96
- @sections.find {|s| s.version == version } || create_section(version)
97
- end
98
-
99
- private def create_section(version)
100
- section = Section[version:, date: nil, categories: {}]
101
- @sections.unshift(section)
102
- section
95
+ # Find a section by version
96
+ #
97
+ # @param version [MODVersion, String] target version (or Changelog::UNRELEASED)
98
+ # @return [Section]
99
+ # @raise [InvalidArgumentError] if the version is not found
100
+ def find_section(version)
101
+ @sections.find {|s| s.version == version } or raise InvalidArgumentError, "version not found: #{version}"
103
102
  end
104
103
 
105
- private def format_section(section)
106
- lines = [SEPARATOR]
104
+ # Format a section as plain text (without separator line)
105
+ #
106
+ # @param section [Section] changelog section
107
+ # @return [String]
108
+ def format_section(section)
109
+ lines = []
107
110
  lines << "Version: #{section.version}"
108
111
  lines << "Date: #{section.date}" if section.date
109
112
  section.categories.each do |cat, entries|
@@ -117,6 +120,16 @@ module Factorix
117
120
  lines.join("\n")
118
121
  end
119
122
 
123
+ private def find_or_create_section(version)
124
+ @sections.find {|s| s.version == version } || create_section(version)
125
+ end
126
+
127
+ private def create_section(version)
128
+ section = Section[version:, date: nil, categories: {}]
129
+ @sections.unshift(section)
130
+ section
131
+ end
132
+
120
133
  # Parslet grammar for Factorio changelog.txt
121
134
  class Grammar < Parslet::Parser
122
135
  rule(:newline) { str("\r\n") | str("\n") }
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+
5
+ module Factorix
6
+ class CLI
7
+ module Commands
8
+ module MOD
9
+ module Changelog
10
+ # Extract a specific version's changelog section
11
+ class Extract < Base
12
+ desc "Extract a changelog section for a specific version"
13
+
14
+ option :version, required: true, desc: "Version (X.Y.Z or Unreleased)"
15
+ option :json, type: :flag, default: false, desc: "Output in JSON format"
16
+ option :changelog, default: "changelog.txt", desc: "Path to changelog file"
17
+
18
+ # @param version [String] version string (X.Y.Z or Unreleased)
19
+ # @param json [Boolean] output in JSON format
20
+ # @param changelog [String] path to changelog file
21
+ # @return [void]
22
+ def call(version:, json: false, changelog: "changelog.txt", **)
23
+ target_version = version.casecmp("unreleased").zero? ? Factorix::Changelog::UNRELEASED : MODVersion.from_string(version)
24
+ log = Factorix::Changelog.load(Pathname(changelog))
25
+ section = log.find_section(target_version)
26
+
27
+ if json
28
+ out.puts JSON.pretty_generate(version: section.version.to_s, date: section.date, entries: section.categories)
29
+ else
30
+ out.puts log.format_section(section)
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
data/lib/factorix/cli.rb CHANGED
@@ -21,6 +21,7 @@ module Factorix
21
21
  register "completion", Commands::Completion
22
22
  register "mod changelog add", Commands::MOD::Changelog::Add
23
23
  register "mod changelog check", Commands::MOD::Changelog::Check
24
+ register "mod changelog extract", Commands::MOD::Changelog::Extract
24
25
  register "mod changelog release", Commands::MOD::Changelog::Release
25
26
  register "mod check", Commands::MOD::Check
26
27
  register "mod list", Commands::MOD::List
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Factorix
4
- VERSION = "0.9.0"
4
+ VERSION = "0.9.1"
5
5
  public_constant :VERSION
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: factorix
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - OZAWA Sakuro
@@ -270,6 +270,7 @@ files:
270
270
  - lib/factorix/cli/commands/man.rb
271
271
  - lib/factorix/cli/commands/mod/changelog/add.rb
272
272
  - lib/factorix/cli/commands/mod/changelog/check.rb
273
+ - lib/factorix/cli/commands/mod/changelog/extract.rb
273
274
  - lib/factorix/cli/commands/mod/changelog/release.rb
274
275
  - lib/factorix/cli/commands/mod/check.rb
275
276
  - lib/factorix/cli/commands/mod/disable.rb