spreen-wiki 0.1.0 → 0.3.0
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/LICENSE.txt +0 -0
- data/README.md +12 -11
- data/exe/{spreen → wiki-organise} +2 -2
- data/lib/spreen-wiki.rb +2 -2
- data/lib/spreen_wiki/application.rb +149 -0
- data/lib/spreen_wiki/cli.rb +157 -0
- data/lib/spreen_wiki/configuration.rb +215 -0
- data/lib/spreen_wiki/home.rb +100 -0
- data/lib/spreen_wiki/sidebar.rb +48 -0
- data/lib/{spreen/wiki → spreen_wiki}/templates/category/english.md +0 -0
- data/lib/{spreen/wiki → spreen_wiki}/templates/category/japanese.md +0 -0
- data/lib/{spreen/wiki → spreen_wiki}/templates/owner/english.md +0 -0
- data/lib/{spreen/wiki → spreen_wiki}/templates/owner/japanese.md +0 -0
- data/lib/spreen_wiki/unknown_wiki_count_list_exporter.rb +59 -0
- data/lib/spreen_wiki/unknown_wiki_list_exporter_for_llm.rb +51 -0
- data/lib/{spreen/wiki → spreen_wiki}/version.rb +2 -4
- data/lib/spreen_wiki.rb +18 -0
- data/sig/generated/spreen-wiki.rbs +0 -0
- data/sig/generated/spreen_wiki/application.rbs +91 -0
- data/sig/generated/spreen_wiki/cli.rbs +68 -0
- data/sig/generated/spreen_wiki/configuration.rbs +148 -0
- data/sig/generated/spreen_wiki/home.rbs +52 -0
- data/sig/generated/spreen_wiki/sidebar.rbs +29 -0
- data/sig/generated/spreen_wiki/unknown_wiki_count_list_exporter.rbs +38 -0
- data/sig/generated/spreen_wiki/unknown_wiki_list_exporter_for_llm.rbs +35 -0
- data/sig/generated/spreen_wiki/version.rbs +5 -0
- data/sig/generated/spreen_wiki.rbs +8 -0
- data/sig/generated/test/application_test.rbs +0 -0
- data/sig/generated/test/configuration_test.rbs +0 -0
- data/sig/generated/test/home_test.rbs +0 -0
- data/sig/generated/test/sidebar_test.rbs +0 -0
- data/sig/generated/test/unknown_wiki_count_list_exporter_test.rbs +0 -0
- data/sig/generated/test/unknown_wiki_list_exporter_for_llm_test.rbs +0 -0
- metadata +25 -25
- data/lib/spreen/wiki/application.rb +0 -151
- data/lib/spreen/wiki/cli.rb +0 -159
- data/lib/spreen/wiki/configuration.rb +0 -217
- data/lib/spreen/wiki/home.rb +0 -102
- data/lib/spreen/wiki/sidebar.rb +0 -50
- data/lib/spreen/wiki/unknown_wiki_count_list_exporter.rb +0 -61
- data/lib/spreen/wiki/unknown_wiki_list_exporter_for_llm.rb +0 -53
- data/lib/spreen/wiki.rb +0 -20
- data/sig/generated/spreen/wiki/application.rbs +0 -93
- data/sig/generated/spreen/wiki/cli.rbs +0 -70
- data/sig/generated/spreen/wiki/configuration.rbs +0 -150
- data/sig/generated/spreen/wiki/home.rbs +0 -54
- data/sig/generated/spreen/wiki/sidebar.rbs +0 -31
- data/sig/generated/spreen/wiki/unknown_wiki_count_list_exporter.rbs +0 -40
- data/sig/generated/spreen/wiki/unknown_wiki_list_exporter_for_llm.rbs +0 -37
- data/sig/generated/spreen/wiki/version.rbs +0 -7
- data/sig/generated/spreen/wiki.rbs +0 -10
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Generated from lib/spreen_wiki/unknown_wiki_count_list_exporter.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module SpreenWiki
|
|
4
|
+
# Writes a sorted text report of how many wikis exist under each of the
|
|
5
|
+
# configured "unknown owner/category" namespaces.
|
|
6
|
+
class UnknownWikiCountListExporter < Application
|
|
7
|
+
DEFAULT_OUTPUT_FILENAME: ::String
|
|
8
|
+
|
|
9
|
+
# @rbs base_path: String
|
|
10
|
+
# @rbs group_by: String
|
|
11
|
+
# @rbs language: String
|
|
12
|
+
# @rbs home_overflow: (bool | String)
|
|
13
|
+
# @rbs output: String?
|
|
14
|
+
# @rbs **options: untyped
|
|
15
|
+
# @rbs return: void
|
|
16
|
+
def initialize: (?base_path: String, ?group_by: String, ?language: String, ?home_overflow: bool | String, ?output: String?, **untyped) -> void
|
|
17
|
+
|
|
18
|
+
# @rbs return: [Array[String], String]
|
|
19
|
+
def run: () -> [ Array[String], String ]
|
|
20
|
+
|
|
21
|
+
private
|
|
22
|
+
|
|
23
|
+
attr_reader path_to_export: String
|
|
24
|
+
|
|
25
|
+
# @rbs filename: String
|
|
26
|
+
# @rbs return: String
|
|
27
|
+
def resolve_output_path: (String filename) -> String
|
|
28
|
+
|
|
29
|
+
# @rbs return: Array[String]
|
|
30
|
+
def namespace_list: () -> Array[String]
|
|
31
|
+
|
|
32
|
+
# @rbs return: Array[String]
|
|
33
|
+
def missing_count_list_by_namespace: () -> Array[String]
|
|
34
|
+
|
|
35
|
+
# @rbs return: Array[String]
|
|
36
|
+
def count_list_by_namespace: () -> Array[String]
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Generated from lib/spreen_wiki/unknown_wiki_list_exporter_for_llm.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module SpreenWiki
|
|
4
|
+
# Writes a flat list of the wikis under the configured "unknown
|
|
5
|
+
# owner/category" namespace in a form suitable for feeding to an LLM.
|
|
6
|
+
class UnknownWikiListExporterForLLM < Application
|
|
7
|
+
DEFAULT_OUTPUT_FILENAME: ::String
|
|
8
|
+
|
|
9
|
+
# @rbs base_path: String
|
|
10
|
+
# @rbs group_by: String
|
|
11
|
+
# @rbs language: String
|
|
12
|
+
# @rbs home_overflow: (bool | String)
|
|
13
|
+
# @rbs output: String?
|
|
14
|
+
# @rbs **options: untyped
|
|
15
|
+
# @rbs return: void
|
|
16
|
+
def initialize: (?base_path: String, ?group_by: String, ?language: String, ?home_overflow: bool | String, ?output: String?, **untyped) -> void
|
|
17
|
+
|
|
18
|
+
# @rbs return: String
|
|
19
|
+
def run: () -> String
|
|
20
|
+
|
|
21
|
+
private
|
|
22
|
+
|
|
23
|
+
attr_reader path_to_export: String
|
|
24
|
+
|
|
25
|
+
# @rbs filename: String
|
|
26
|
+
# @rbs return: String
|
|
27
|
+
def resolve_output_path: (String filename) -> String
|
|
28
|
+
|
|
29
|
+
# @rbs return: String
|
|
30
|
+
def target_namespace: () -> String
|
|
31
|
+
|
|
32
|
+
# @rbs return: Array[String]
|
|
33
|
+
def unknown_wiki_list_for_llm: () -> Array[String]
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Generated from lib/spreen_wiki.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
# Spreens a GitHub wiki — the falcon's stoop, then the preen: generates
|
|
4
|
+
# Home.md and _Sidebar.md grouped by the Owner/Category declared on the
|
|
5
|
+
# first line of each page, and exports reports of the pages whose owner
|
|
6
|
+
# or category is unknown.
|
|
7
|
+
module SpreenWiki
|
|
8
|
+
end
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: spreen-wiki
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- hayat01sh1da
|
|
@@ -14,37 +14,37 @@ description: Spreen — the falcon's stoop, then the preen. Generates Home.md an
|
|
|
14
14
|
line of each page (English and Japanese labels built in, extensible via .spreen.yml),
|
|
15
15
|
and exports reports of the pages whose owner or category is unknown.
|
|
16
16
|
executables:
|
|
17
|
-
-
|
|
17
|
+
- wiki-organise
|
|
18
18
|
extensions: []
|
|
19
19
|
extra_rdoc_files: []
|
|
20
20
|
files:
|
|
21
21
|
- LICENSE.txt
|
|
22
22
|
- README.md
|
|
23
|
-
- exe/
|
|
23
|
+
- exe/wiki-organise
|
|
24
24
|
- lib/spreen-wiki.rb
|
|
25
|
-
- lib/
|
|
26
|
-
- lib/
|
|
27
|
-
- lib/
|
|
28
|
-
- lib/
|
|
29
|
-
- lib/
|
|
30
|
-
- lib/
|
|
31
|
-
- lib/
|
|
32
|
-
- lib/
|
|
33
|
-
- lib/
|
|
34
|
-
- lib/
|
|
35
|
-
- lib/
|
|
36
|
-
- lib/
|
|
37
|
-
- lib/
|
|
25
|
+
- lib/spreen_wiki.rb
|
|
26
|
+
- lib/spreen_wiki/application.rb
|
|
27
|
+
- lib/spreen_wiki/cli.rb
|
|
28
|
+
- lib/spreen_wiki/configuration.rb
|
|
29
|
+
- lib/spreen_wiki/home.rb
|
|
30
|
+
- lib/spreen_wiki/sidebar.rb
|
|
31
|
+
- lib/spreen_wiki/templates/category/english.md
|
|
32
|
+
- lib/spreen_wiki/templates/category/japanese.md
|
|
33
|
+
- lib/spreen_wiki/templates/owner/english.md
|
|
34
|
+
- lib/spreen_wiki/templates/owner/japanese.md
|
|
35
|
+
- lib/spreen_wiki/unknown_wiki_count_list_exporter.rb
|
|
36
|
+
- lib/spreen_wiki/unknown_wiki_list_exporter_for_llm.rb
|
|
37
|
+
- lib/spreen_wiki/version.rb
|
|
38
38
|
- sig/generated/spreen-wiki.rbs
|
|
39
|
-
- sig/generated/
|
|
40
|
-
- sig/generated/
|
|
41
|
-
- sig/generated/
|
|
42
|
-
- sig/generated/
|
|
43
|
-
- sig/generated/
|
|
44
|
-
- sig/generated/
|
|
45
|
-
- sig/generated/
|
|
46
|
-
- sig/generated/
|
|
47
|
-
- sig/generated/
|
|
39
|
+
- sig/generated/spreen_wiki.rbs
|
|
40
|
+
- sig/generated/spreen_wiki/application.rbs
|
|
41
|
+
- sig/generated/spreen_wiki/cli.rbs
|
|
42
|
+
- sig/generated/spreen_wiki/configuration.rbs
|
|
43
|
+
- sig/generated/spreen_wiki/home.rbs
|
|
44
|
+
- sig/generated/spreen_wiki/sidebar.rbs
|
|
45
|
+
- sig/generated/spreen_wiki/unknown_wiki_count_list_exporter.rbs
|
|
46
|
+
- sig/generated/spreen_wiki/unknown_wiki_list_exporter_for_llm.rbs
|
|
47
|
+
- sig/generated/spreen_wiki/version.rbs
|
|
48
48
|
- sig/generated/test/application_test.rbs
|
|
49
49
|
- sig/generated/test/configuration_test.rbs
|
|
50
50
|
- sig/generated/test/home_test.rbs
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
# rbs_inline: enabled
|
|
3
|
-
|
|
4
|
-
require_relative 'configuration'
|
|
5
|
-
|
|
6
|
-
module Spreen
|
|
7
|
-
module Wiki
|
|
8
|
-
# Base class for the wiki-organising commands. Loads the wiki tree under
|
|
9
|
-
# base_path, groups it by Owner or Category in either English or Japanese,
|
|
10
|
-
# and exposes the resulting maps to its subclasses. Grouping criteria,
|
|
11
|
-
# languages and labels are resolved through Configuration and can be
|
|
12
|
-
# extended via a `.spreen.yml` file.
|
|
13
|
-
class Application
|
|
14
|
-
class NotImplementedError < StandardError; end
|
|
15
|
-
|
|
16
|
-
# @rbs base_path: String
|
|
17
|
-
# @rbs group_by: String
|
|
18
|
-
# @rbs language: String
|
|
19
|
-
# @rbs home_overflow: (bool | String)
|
|
20
|
-
# @rbs **options: untyped
|
|
21
|
-
# @rbs return: untyped
|
|
22
|
-
def self.run(base_path: Dir.pwd, group_by: 'Owner', language: 'English', home_overflow: 'false', **)
|
|
23
|
-
instance = new(base_path:, group_by:, language:, home_overflow:, **)
|
|
24
|
-
instance.validate!
|
|
25
|
-
instance.run
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
# @rbs base_path: String
|
|
29
|
-
# @rbs group_by: String
|
|
30
|
-
# @rbs language: String
|
|
31
|
-
# @rbs home_overflow: (bool | String)
|
|
32
|
-
# @rbs config: Configuration?
|
|
33
|
-
# @rbs **options: untyped
|
|
34
|
-
# @rbs return: void
|
|
35
|
-
def initialize(base_path: Dir.pwd, group_by: 'Owner', language: 'English', home_overflow: 'false',
|
|
36
|
-
config: nil, **)
|
|
37
|
-
@base_path = base_path
|
|
38
|
-
@group_by = group_by
|
|
39
|
-
@language = language
|
|
40
|
-
@home_overflow = parse_home_overflow(home_overflow)
|
|
41
|
-
@config = config || Configuration.new(base_path:, **)
|
|
42
|
-
@path_to_home = File.join(base_path, 'Home.md')
|
|
43
|
-
@path_to_sidebar = File.join(base_path, '_Sidebar.md')
|
|
44
|
-
@paths_to_wikis = Dir[File.join(base_path, '**', '*.md')]
|
|
45
|
-
@excluded_paths = @config.excluded_dirs.flat_map { |dir| Dir[File.join(base_path, dir, '**', '*.md')] }
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
# @rbs return: void
|
|
49
|
-
def validate!
|
|
50
|
-
raise ArgumentError, "Invalid group_by: `#{group_by}`" unless config.group_bys.include?(group_by)
|
|
51
|
-
raise ArgumentError, "Invalid language: `#{language}`" unless config.languages(group_by).include?(language)
|
|
52
|
-
|
|
53
|
-
validate_home_overflow!
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
# @rbs return: untyped
|
|
57
|
-
def run
|
|
58
|
-
raise NotImplementedError, 'This method must be implemented in each subclass.'
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
private
|
|
62
|
-
|
|
63
|
-
attr_reader :base_path,
|
|
64
|
-
:group_by,
|
|
65
|
-
:language,
|
|
66
|
-
:home_overflow,
|
|
67
|
-
:config,
|
|
68
|
-
:path_to_home,
|
|
69
|
-
:path_to_sidebar,
|
|
70
|
-
:paths_to_wikis,
|
|
71
|
-
:excluded_paths
|
|
72
|
-
|
|
73
|
-
# @rbs return: void
|
|
74
|
-
def validate_home_overflow!
|
|
75
|
-
return if [true, false].include?(home_overflow)
|
|
76
|
-
|
|
77
|
-
raise ArgumentError, "Invalid home_overflow: `#{home_overflow}` must be boolean"
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
# @rbs raw: (bool | String)
|
|
81
|
-
# @rbs return: (bool | String)
|
|
82
|
-
def parse_home_overflow(raw)
|
|
83
|
-
case raw
|
|
84
|
-
when 'true' then true
|
|
85
|
-
when 'false' then false
|
|
86
|
-
else raw
|
|
87
|
-
end
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
# @rbs return: Array[String]
|
|
91
|
-
def target_paths
|
|
92
|
-
@target_paths ||= paths_to_wikis.reject do |path_to_wiki|
|
|
93
|
-
path_to_wiki == path_to_home ||
|
|
94
|
-
path_to_wiki == path_to_sidebar ||
|
|
95
|
-
excluded_paths.include?(path_to_wiki)
|
|
96
|
-
end
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
# @rbs return: Regexp
|
|
100
|
-
def target_regexp
|
|
101
|
-
@target_regexp ||= config.target_regexp(group_by)
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
# @rbs return: String
|
|
105
|
-
def no_declaration
|
|
106
|
-
@no_declaration ||= config.no_declaration(group_by, language)
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
# @rbs return: Hash[String, Array[String]]
|
|
110
|
-
def wiki_maps_with_namespace
|
|
111
|
-
@wiki_maps_with_namespace ||= begin
|
|
112
|
-
named = Hash.new { |hash, namespace| hash[namespace] = [] } #: Hash[String, Array[String]]
|
|
113
|
-
undeclared = Hash.new { |hash, namespace| hash[namespace] = [] } #: Hash[String, Array[String]]
|
|
114
|
-
target_paths.each { |target_path| populate_namespace(target_path, named, undeclared) }
|
|
115
|
-
named.sort.to_h.merge(undeclared)
|
|
116
|
-
end
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
# @rbs target_path: String
|
|
120
|
-
# @rbs named: Hash[String, Array[String]]
|
|
121
|
-
# @rbs undeclared: Hash[String, Array[String]]
|
|
122
|
-
# @rbs return: void
|
|
123
|
-
def populate_namespace(target_path, named, undeclared)
|
|
124
|
-
return unless File.exist?(target_path)
|
|
125
|
-
|
|
126
|
-
namespace = namespace_for(target_path)
|
|
127
|
-
bucket = namespace == no_declaration ? undeclared : named
|
|
128
|
-
bucket[namespace] << File.basename(target_path)
|
|
129
|
-
end
|
|
130
|
-
|
|
131
|
-
# @rbs target_path: String
|
|
132
|
-
# @rbs return: String
|
|
133
|
-
def namespace_for(target_path)
|
|
134
|
-
declaration = File.open(target_path, &:gets)
|
|
135
|
-
return no_declaration unless declaration&.start_with?(target_regexp)
|
|
136
|
-
|
|
137
|
-
declaration.chomp.gsub(target_regexp, '')
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
# @rbs return: Hash[String, Array[String]]
|
|
141
|
-
def owned_wiki_maps
|
|
142
|
-
@owned_wiki_maps ||= wiki_maps_with_namespace.select { |namespace, _| namespace.include?('@') }
|
|
143
|
-
end
|
|
144
|
-
|
|
145
|
-
# @rbs return: Hash[String, Array[String]]
|
|
146
|
-
def plain_wiki_maps
|
|
147
|
-
@plain_wiki_maps ||= wiki_maps_with_namespace.reject { |namespace, _| namespace.include?('@') }
|
|
148
|
-
end
|
|
149
|
-
end
|
|
150
|
-
end
|
|
151
|
-
end
|
data/lib/spreen/wiki/cli.rb
DELETED
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
# rbs_inline: enabled
|
|
3
|
-
|
|
4
|
-
require 'optparse'
|
|
5
|
-
require_relative 'version'
|
|
6
|
-
require_relative 'home'
|
|
7
|
-
require_relative 'sidebar'
|
|
8
|
-
require_relative 'unknown_wiki_count_list_exporter'
|
|
9
|
-
require_relative 'unknown_wiki_list_exporter_for_llm'
|
|
10
|
-
|
|
11
|
-
module Spreen
|
|
12
|
-
module Wiki
|
|
13
|
-
# Command line interface behind the `spreen` executable:
|
|
14
|
-
# `spreen <update|count-report|llm-export> [options]`.
|
|
15
|
-
class CLI
|
|
16
|
-
HELP = <<~HELP
|
|
17
|
-
Usage: spreen <command> [options]
|
|
18
|
-
|
|
19
|
-
Commands:
|
|
20
|
-
update Regenerate Home.md and _Sidebar.md from the wiki tree
|
|
21
|
-
count-report Export a count report of the unknown-namespace wikis
|
|
22
|
-
llm-export Export the unknown-namespace wiki list for an LLM
|
|
23
|
-
version Print the version
|
|
24
|
-
|
|
25
|
-
Run `spreen <command> --help` to list the command's options.
|
|
26
|
-
HELP
|
|
27
|
-
|
|
28
|
-
# Flags shared by every command, mapped to the keyword arguments of the
|
|
29
|
-
# underlying classes. --exclude and the per-command flags are wired up
|
|
30
|
-
# separately because they need a type or a fixed value.
|
|
31
|
-
COMMON_OPTIONS = {
|
|
32
|
-
'--path PATH' => [:base_path, 'Path to the wiki clone (default: current directory)'],
|
|
33
|
-
'--group-by GROUP_BY' => [:group_by, 'Grouping criteria (default: Owner)'],
|
|
34
|
-
'--language LANGUAGE' => [:language, 'Language of the labels (default: English)'],
|
|
35
|
-
'--org ORGANISATION' => [:organisation, 'GitHub organisation/user hosting the wiki'],
|
|
36
|
-
'--repo REPOSITORY' => [:repository, 'GitHub repository whose wiki is organised'],
|
|
37
|
-
'--wiki-url URL' => [:wiki_url, 'Wiki URL (overrides the one derived from --org/--repo)'],
|
|
38
|
-
'--template-dir DIR' => [:template_dir, 'Directory of <group_by>/<language>.md Home templates'],
|
|
39
|
-
'--config FILE' => [:config_path, 'Config file path (default: <path>/.spreen.yml)']
|
|
40
|
-
}.freeze
|
|
41
|
-
|
|
42
|
-
# @rbs argv: Array[String]
|
|
43
|
-
# @rbs return: Integer
|
|
44
|
-
def self.start(argv = ARGV)
|
|
45
|
-
new(argv).run
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
# @rbs argv: Array[String]
|
|
49
|
-
# @rbs return: void
|
|
50
|
-
def initialize(argv)
|
|
51
|
-
@argv = argv.dup
|
|
52
|
-
@options = { base_path: Dir.pwd, group_by: 'Owner', language: 'English', home_overflow: 'false' }
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
# @rbs return: Integer
|
|
56
|
-
def run
|
|
57
|
-
command = argv.shift
|
|
58
|
-
case command
|
|
59
|
-
when 'update', 'count-report', 'llm-export' then execute(command)
|
|
60
|
-
when 'version', '--version', '-v' then print_version
|
|
61
|
-
when nil, 'help', '--help', '-h' then print_help(command)
|
|
62
|
-
else unknown_command(command)
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
private
|
|
67
|
-
|
|
68
|
-
attr_reader :argv, :options
|
|
69
|
-
|
|
70
|
-
# @rbs command: String
|
|
71
|
-
# @rbs return: Integer
|
|
72
|
-
def execute(command)
|
|
73
|
-
parser(command).parse!(argv)
|
|
74
|
-
__send__(command.tr('-', '_'))
|
|
75
|
-
0
|
|
76
|
-
rescue ArgumentError, OptionParser::ParseError => e
|
|
77
|
-
warn e.message
|
|
78
|
-
1
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
# @rbs return: Integer
|
|
82
|
-
def print_version
|
|
83
|
-
puts VERSION
|
|
84
|
-
0
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
# @rbs command: String?
|
|
88
|
-
# @rbs return: Integer
|
|
89
|
-
def print_help(command)
|
|
90
|
-
puts HELP
|
|
91
|
-
command.nil? ? 1 : 0
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
# @rbs command: String
|
|
95
|
-
# @rbs return: Integer
|
|
96
|
-
def unknown_command(command)
|
|
97
|
-
warn "Unknown command: `#{command}`"
|
|
98
|
-
warn HELP
|
|
99
|
-
1
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
# @rbs return: void
|
|
103
|
-
def update
|
|
104
|
-
wiki_url = Home.run(**options)
|
|
105
|
-
Sidebar.run(**options)
|
|
106
|
-
puts 'Updated Home.md and _Sidebar.md.'
|
|
107
|
-
puts "Check them out at '#{wiki_url}' !!" if wiki_url
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
# @rbs return: void
|
|
111
|
-
def count_report
|
|
112
|
-
count_list_by_namespace, path_to_export = UnknownWikiCountListExporter.run(**options)
|
|
113
|
-
puts count_list_by_namespace
|
|
114
|
-
puts "Exported the unknown wiki count report to '#{path_to_export}'."
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
# @rbs return: void
|
|
118
|
-
def llm_export
|
|
119
|
-
path_to_export = UnknownWikiListExporterForLLM.run(**options)
|
|
120
|
-
puts "Exported the unknown wiki list for LLM to '#{path_to_export}'."
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
# @rbs command: String
|
|
124
|
-
# @rbs return: OptionParser
|
|
125
|
-
def parser(command)
|
|
126
|
-
OptionParser.new("Usage: spreen #{command} [options]") do |opt|
|
|
127
|
-
add_common_options(opt)
|
|
128
|
-
add_command_options(opt, command)
|
|
129
|
-
end
|
|
130
|
-
end
|
|
131
|
-
|
|
132
|
-
# @rbs opt: OptionParser
|
|
133
|
-
# @rbs return: void
|
|
134
|
-
def add_common_options(opt)
|
|
135
|
-
COMMON_OPTIONS.each do |flag, (key, description)|
|
|
136
|
-
opt.on(flag, description) { |value| options[key] = value }
|
|
137
|
-
end
|
|
138
|
-
opt.on('--exclude DIR1,DIR2', Array, 'Directories to skip while scanning') do |dirs|
|
|
139
|
-
options[:excluded_dirs] = dirs
|
|
140
|
-
end
|
|
141
|
-
end
|
|
142
|
-
|
|
143
|
-
# @rbs opt: OptionParser
|
|
144
|
-
# @rbs command: String
|
|
145
|
-
# @rbs return: void
|
|
146
|
-
def add_command_options(opt, command)
|
|
147
|
-
if command == 'update'
|
|
148
|
-
opt.on('--overflow', 'Split Home into per-namespace pages under wikis-by-owner/') do
|
|
149
|
-
options[:home_overflow] = 'true'
|
|
150
|
-
end
|
|
151
|
-
else
|
|
152
|
-
opt.on('--output FILENAME', 'Export filename (relative to --path unless absolute)') do |filename|
|
|
153
|
-
options[:output] = filename
|
|
154
|
-
end
|
|
155
|
-
end
|
|
156
|
-
end
|
|
157
|
-
end
|
|
158
|
-
end
|
|
159
|
-
end
|