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 +4 -4
- data/CHANGELOG.md +6 -0
- data/completion/_factorix.bash +10 -1
- data/completion/_factorix.fish +6 -0
- data/completion/_factorix.zsh +8 -0
- data/lib/factorix/changelog.rb +24 -11
- data/lib/factorix/cli/commands/mod/changelog/extract.rb +38 -0
- data/lib/factorix/cli.rb +1 -0
- data/lib/factorix/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5212e69bd41c45ceffb0fd42e889868b706b0481e6a07567c98b2cce439bb5fc
|
|
4
|
+
data.tar.gz: e2386ba4154617497efbeddea3537b58eb164dd5af66e963c325d06626536895
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 62ece69fa0e7028367dff967cfb6e5d93ba4c5413be84b9a38cd13466687202a9417b57c09b4b137ca26e149a556b1063d086342747ae95590ace736c492efa6
|
|
7
|
+
data.tar.gz: 8687814b5cb8f3af5e695db5765117c113de95d09fa361a87e04222f106e30abb935be426eb775751410d0181ee73c9171af9380fea5358d2ae936e9c12ec267
|
data/CHANGELOG.md
CHANGED
data/completion/_factorix.bash
CHANGED
|
@@ -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"))
|
data/completion/_factorix.fish
CHANGED
|
@@ -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
|
data/completion/_factorix.zsh
CHANGED
|
@@ -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 \
|
data/lib/factorix/changelog.rb
CHANGED
|
@@ -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
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
@sections.
|
|
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
|
-
|
|
106
|
-
|
|
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
|
data/lib/factorix/version.rb
CHANGED
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.
|
|
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
|