milestoner 15.3.0 → 16.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4711636d774e0173cfac11128d0e4723037104419f15fdca2e297120c4229180
4
- data.tar.gz: 002f4e7a93156a6f57e71aba9cae317bfe1908aaf69a760ef5ad93e2d269f4f7
3
+ metadata.gz: 463ef8094d1ed6ad4cec764411a8317e4895f058eb3562dd2debdff7c03a45a2
4
+ data.tar.gz: f746a08a1c77a63ad78a0b07cd3aa112ec0ca9c455d813422995bfabcfcdcf15
5
5
  SHA512:
6
- metadata.gz: 5cfec92e2450c2b94824ca9f2945f29ef0360354911abb76826c9cc24db7409486d1287640e3732cfc8b131a16ee0d56026e8383aca07fa4862632e3e5f978b7
7
- data.tar.gz: 393184977a7bb20b2b5be79e87351452b3c964030fc7d090cc1911ab9242b2f3b1cef96bd80c0360b3bef149db068bd7a81d611a88dbc569fa33e5ef35b1d7f6
6
+ metadata.gz: b32140a8b3ad32fcd3aa5a896f55a1fcc9adbb3181309d8539b0983828b1cb82bb7b64cf87b630c69362b5a16130879528bac0036c2fc4e1e3c4c5828da92b40
7
+ data.tar.gz: 33eb20a7c9f937d1cd913987424cb7a4915d8fb2869aa65a516be0fb892579faa7c5c6174cf88f8747dd3dffaaf55004f5e843a48afbbd36048b73022c310efa
checksums.yaml.gz.sig CHANGED
Binary file
data/README.adoc CHANGED
@@ -68,26 +68,22 @@ gem install milestoner
68
68
  From the command line, type: `milestoner --help`
69
69
 
70
70
  ....
71
- USAGE:
72
- -c, --config ACTION Manage gem configuration. Actions: edit || view.
73
- -h, --help Show this message.
74
- -P, --publish VERSION Tag and push milestone to remote repository.
75
- -s, --status Show project status.
76
- -v, --version Show gem version.
71
+ USAGE
72
+ milestoner [OPTIONS]
73
+ milestoner COMMAND [OPTIONS]
74
+
75
+ OPTIONS
76
+ -p, --publish VERSION Publish milestone.
77
+ (tags and pushes to remote repository)
78
+ -s, --status Show project status.
79
+ -v, --version Show version.
80
+ -h, --help [COMMAND] Show this message.
81
+
82
+ COMMANDS
83
+ config Manage configuration.
84
+ Path is dynamic per current directory.
77
85
  ....
78
86
 
79
- Examples:
80
-
81
- [source,bash]
82
- ----
83
- milestoner --config edit
84
- milestoner --config view
85
- milestoner --help
86
- milestoner --publish 0.1.0
87
- milestoner --status
88
- milestoner --version
89
- ----
90
-
91
87
  === Customization
92
88
 
93
89
  This gem can be configured via a global configuration:
@@ -102,9 +98,9 @@ The default configuration is as follows:
102
98
 
103
99
  [source,yaml]
104
100
  ----
105
- :documentation:
106
- :format: "adoc"
107
- :prefixes:
101
+ documentation:
102
+ format: "adoc"
103
+ prefixes:
108
104
  - Fixed
109
105
  - Added
110
106
  - Updated
@@ -112,10 +108,7 @@ The default configuration is as follows:
112
108
  - Refactored
113
109
  ----
114
110
 
115
- Feel free to take this default configuration, modify, and save as your own custom
116
- `+configuration.yml+`.
117
-
118
- The `+configuration.yml+` file can be configured as follows:
111
+ The `configuration.yml` file can be configured as follows:
119
112
 
120
113
  * *Documentation Format* (i.e. `documentation`): Determines what format the release notes should be
121
114
  rendered as. This effects both status information from the command line and the release notes
@@ -126,7 +119,7 @@ The `+configuration.yml+` file can be configured as follows:
126
119
  define Git commit prefixes that match your style. _NOTE: Prefix order is important with the first
127
120
  prefix defined taking precedence over the second and so forth._ Special characters are allowed for
128
121
  prefixes but should be enclosed in quotes. To disable prefix usage completely, use an empty array.
129
- Example: `:prefixes: []`.
122
+ Example: `prefixes: []`.
130
123
 
131
124
  == Security
132
125
 
@@ -1,15 +1,29 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "refinements/structs"
4
+ require "sod"
5
+
3
6
  module Milestoner
4
7
  module CLI
5
8
  module Actions
6
9
  # Handles tag creation and pushing of tag to local repository.
7
- class Publish
8
- def initialize publisher: Tags::Publisher.new
10
+ class Publish < Sod::Action
11
+ include Import[:configuration]
12
+
13
+ using Refinements::Structs
14
+
15
+ description "Publish milestone."
16
+
17
+ ancillary "(tags and pushes to remote repository)"
18
+
19
+ on %w[-p --publish], argument: "VERSION"
20
+
21
+ def initialize(publisher: Tags::Publisher.new, **)
22
+ super(**)
9
23
  @publisher = publisher
10
24
  end
11
25
 
12
- def call(configuration) = publisher.call(configuration)
26
+ def call(version) = publisher.call configuration.merge(version:)
13
27
 
14
28
  private
15
29
 
@@ -1,19 +1,25 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "sod"
4
+
3
5
  module Milestoner
4
6
  module CLI
5
7
  module Actions
6
8
  # Handles listing project status of untagged commit history.
7
- class Status
9
+ class Status < Sod::Action
8
10
  include Milestoner::Import[:kernel, :logger]
9
11
 
12
+ description "Show project status."
13
+
14
+ on %w[-s --status]
15
+
10
16
  def initialize(presenter: Presenters::Commit, categorizer: Commits::Categorizer.new, **)
11
17
  super(**)
12
18
  @presenter = presenter
13
19
  @categorizer = categorizer
14
20
  end
15
21
 
16
- def call
22
+ def call(*)
17
23
  categorizer.call
18
24
  .tap { |records| info "All is quiet." if records.empty? }
19
25
  .map { |record| presenter.new(record).line_item }
@@ -1,37 +1,40 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "core"
3
+ require "sod"
4
4
 
5
5
  module Milestoner
6
6
  module CLI
7
7
  # The main Command Line Interface (CLI) object.
8
8
  class Shell
9
- include Actions::Import[:config, :kernel, :logger, :publish, :status, :specification]
9
+ include Import[:defaults_path, :xdg_config, :specification]
10
10
 
11
- def initialize(parser: Parser.new, **)
11
+ def initialize(context: Sod::Context, dsl: Sod, **)
12
12
  super(**)
13
- @parser = parser
13
+ @context = context
14
+ @dsl = dsl
14
15
  end
15
16
 
16
- def call arguments = Core::EMPTY_ARRAY
17
- act_on parser.call(arguments)
18
- rescue OptionParser::ParseError, Error => error
19
- logger.error { error.message }
20
- end
17
+ def call(...) = cli.call(...)
21
18
 
22
19
  private
23
20
 
24
- attr_reader :parser
21
+ attr_reader :context, :dsl
22
+
23
+ def cli
24
+ context = build_context
25
25
 
26
- def act_on configuration
27
- case configuration
28
- in action_config: Symbol => action then config.call action
29
- in action_publish: true then publish.call configuration
30
- in action_status: true then status.call
31
- in action_version: true then kernel.puts specification.labeled_version
32
- else kernel.puts parser.to_s
26
+ dsl.new :milestoner, banner: specification.banner do
27
+ on(Sod::Prefabs::Commands::Config, context:)
28
+ on Actions::Publish
29
+ on Actions::Status
30
+ on(Sod::Prefabs::Actions::Version, context:)
31
+ on Sod::Prefabs::Actions::Help, self
33
32
  end
34
33
  end
34
+
35
+ def build_context
36
+ context[defaults_path:, xdg_config:, version_label: specification.labeled_version]
37
+ end
35
38
  end
36
39
  end
37
40
  end
@@ -46,7 +46,7 @@ module Milestoner
46
46
  def tagged_commits
47
47
  git.tag_last
48
48
  .value_or(nil)
49
- .then { |tag| git.commits("#{tag}..HEAD") }
49
+ .then { |tag| git.commits "#{tag}..HEAD" }
50
50
  .value_or([])
51
51
  end
52
52
 
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "dry/schema"
4
+ require "etcher"
5
+
6
+ Dry::Schema.load_extensions :monads
7
+
8
+ module Milestoner
9
+ module Configuration
10
+ Contract = Dry::Schema.Params do
11
+ required(:documentation_format).filled :string
12
+ required(:prefixes).array :string
13
+ optional(:version).filled :string
14
+ end
15
+ end
16
+ end
@@ -1,6 +1,6 @@
1
- :documentation:
2
- :format: "adoc"
3
- :prefixes:
1
+ documentation:
2
+ format: "adoc"
3
+ prefixes:
4
4
  - Fixed
5
5
  - Added
6
6
  - Updated
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Milestoner
4
+ module Configuration
5
+ # Defines configuration content as the primary source of truth for use throughout the gem.
6
+ Model = Struct.new :documentation_format, :prefixes, :version do
7
+ def initialize(**)
8
+ super
9
+ freeze
10
+ end
11
+ end
12
+ end
13
+ end
@@ -2,7 +2,9 @@
2
2
 
3
3
  require "cogger"
4
4
  require "dry-container"
5
+ require "etcher"
5
6
  require "gitt"
7
+ require "runcom"
6
8
  require "spek"
7
9
 
8
10
  module Milestoner
@@ -10,9 +12,20 @@ module Milestoner
10
12
  module Container
11
13
  extend Dry::Container::Mixin
12
14
 
13
- register(:configuration) { Configuration::Loader.call }
14
- register(:specification) { Spek::Loader.call "#{__dir__}/../../milestoner.gemspec" }
15
+ register :configuration do
16
+ self[:defaults].add_loader(Etcher::Loaders::YAML.new(self[:xdg_config].active))
17
+ .then { |registry| Etcher.call registry }
18
+ end
19
+
20
+ register :defaults do
21
+ Etcher::Registry.new(contract: Configuration::Contract, model: Configuration::Model)
22
+ .add_loader(Etcher::Loaders::YAML.new(self[:defaults_path]))
23
+ end
24
+
15
25
  register(:git) { Gitt::Repository.new }
26
+ register(:defaults_path) { Pathname(__dir__).join("configuration/defaults.yml") }
27
+ register(:xdg_config) { Runcom::Config.new "milestoner/configuration.yml" }
28
+ register(:specification) { Spek::Loader.call "#{__dir__}/../../milestoner.gemspec" }
16
29
  register(:kernel) { Kernel }
17
30
  register(:logger) { Cogger.new formatter: :emoji }
18
31
  end
data/milestoner.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "milestoner"
5
- spec.version = "15.3.0"
5
+ spec.version = "16.0.0"
6
6
  spec.authors = ["Brooke Kuhlmann"]
7
7
  spec.email = ["brooke@alchemists.io"]
8
8
  spec.homepage = "https://alchemists.io/projects/milestoner"
9
- spec.summary = "A command line interface for crafting Git semantically versioned repository tags."
9
+ spec.summary = "A command line interface for managing Git repository milestones."
10
10
  spec.license = "Hippocratic-2.1"
11
11
 
12
12
  spec.metadata = {
@@ -23,16 +23,18 @@ Gem::Specification.new do |spec|
23
23
  spec.cert_chain = [Gem.default_cert_path]
24
24
 
25
25
  spec.required_ruby_version = "~> 3.2"
26
- spec.add_dependency "cogger", "~> 0.8"
27
- spec.add_dependency "core", "~> 0.1"
26
+ spec.add_dependency "cogger", "~> 0.10"
28
27
  spec.add_dependency "dry-container", "~> 0.11"
29
28
  spec.add_dependency "dry-monads", "~> 1.6"
30
- spec.add_dependency "gitt", "~> 1.1"
31
- spec.add_dependency "infusible", "~> 1.0"
32
- spec.add_dependency "refinements", "~> 10.0"
33
- spec.add_dependency "runcom", "~> 9.0"
34
- spec.add_dependency "spek", "~> 1.0"
35
- spec.add_dependency "versionaire", "~> 11.0"
29
+ spec.add_dependency "dry-schema", "~> 1.13"
30
+ spec.add_dependency "etcher", "~> 0.2"
31
+ spec.add_dependency "gitt", "~> 2.0"
32
+ spec.add_dependency "infusible", "~> 2.0"
33
+ spec.add_dependency "refinements", "~> 11.0"
34
+ spec.add_dependency "runcom", "~> 10.0"
35
+ spec.add_dependency "sod", "~> 0.0"
36
+ spec.add_dependency "spek", "~> 2.0"
37
+ spec.add_dependency "versionaire", "~> 12.0"
36
38
  spec.add_dependency "zeitwerk", "~> 2.6"
37
39
 
38
40
  spec.bindir = "exe"
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: milestoner
3
3
  version: !ruby/object:Gem::Version
4
- version: 15.3.0
4
+ version: 16.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brooke Kuhlmann
@@ -35,7 +35,7 @@ cert_chain:
35
35
  3n5C8/6Zh9DYTkpcwPSuIfAga6wf4nXc9m6JAw8AuMLaiWN/r/2s4zJsUHYERJEu
36
36
  gZGm4JqtuSg8pYjPeIJxS960owq+SfuC+jxqmRA54BisFCv/0VOJi7tiJVY=
37
37
  -----END CERTIFICATE-----
38
- date: 2023-04-13 00:00:00.000000000 Z
38
+ date: 2023-06-16 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: cogger
@@ -43,86 +43,114 @@ dependencies:
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: '0.8'
46
+ version: '0.10'
47
47
  type: :runtime
48
48
  prerelease: false
49
49
  version_requirements: !ruby/object:Gem::Requirement
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: '0.8'
53
+ version: '0.10'
54
54
  - !ruby/object:Gem::Dependency
55
- name: core
55
+ name: dry-container
56
56
  requirement: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: '0.1'
60
+ version: '0.11'
61
61
  type: :runtime
62
62
  prerelease: false
63
63
  version_requirements: !ruby/object:Gem::Requirement
64
64
  requirements:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: '0.1'
67
+ version: '0.11'
68
68
  - !ruby/object:Gem::Dependency
69
- name: dry-container
69
+ name: dry-monads
70
70
  requirement: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
- version: '0.11'
74
+ version: '1.6'
75
75
  type: :runtime
76
76
  prerelease: false
77
77
  version_requirements: !ruby/object:Gem::Requirement
78
78
  requirements:
79
79
  - - "~>"
80
80
  - !ruby/object:Gem::Version
81
- version: '0.11'
81
+ version: '1.6'
82
82
  - !ruby/object:Gem::Dependency
83
- name: dry-monads
83
+ name: dry-schema
84
84
  requirement: !ruby/object:Gem::Requirement
85
85
  requirements:
86
86
  - - "~>"
87
87
  - !ruby/object:Gem::Version
88
- version: '1.6'
88
+ version: '1.13'
89
89
  type: :runtime
90
90
  prerelease: false
91
91
  version_requirements: !ruby/object:Gem::Requirement
92
92
  requirements:
93
93
  - - "~>"
94
94
  - !ruby/object:Gem::Version
95
- version: '1.6'
95
+ version: '1.13'
96
+ - !ruby/object:Gem::Dependency
97
+ name: etcher
98
+ requirement: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '0.2'
103
+ type: :runtime
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '0.2'
96
110
  - !ruby/object:Gem::Dependency
97
111
  name: gitt
98
112
  requirement: !ruby/object:Gem::Requirement
99
113
  requirements:
100
114
  - - "~>"
101
115
  - !ruby/object:Gem::Version
102
- version: '1.1'
116
+ version: '2.0'
103
117
  type: :runtime
104
118
  prerelease: false
105
119
  version_requirements: !ruby/object:Gem::Requirement
106
120
  requirements:
107
121
  - - "~>"
108
122
  - !ruby/object:Gem::Version
109
- version: '1.1'
123
+ version: '2.0'
110
124
  - !ruby/object:Gem::Dependency
111
125
  name: infusible
112
126
  requirement: !ruby/object:Gem::Requirement
113
127
  requirements:
114
128
  - - "~>"
115
129
  - !ruby/object:Gem::Version
116
- version: '1.0'
130
+ version: '2.0'
117
131
  type: :runtime
118
132
  prerelease: false
119
133
  version_requirements: !ruby/object:Gem::Requirement
120
134
  requirements:
121
135
  - - "~>"
122
136
  - !ruby/object:Gem::Version
123
- version: '1.0'
137
+ version: '2.0'
124
138
  - !ruby/object:Gem::Dependency
125
139
  name: refinements
140
+ requirement: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - "~>"
143
+ - !ruby/object:Gem::Version
144
+ version: '11.0'
145
+ type: :runtime
146
+ prerelease: false
147
+ version_requirements: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - "~>"
150
+ - !ruby/object:Gem::Version
151
+ version: '11.0'
152
+ - !ruby/object:Gem::Dependency
153
+ name: runcom
126
154
  requirement: !ruby/object:Gem::Requirement
127
155
  requirements:
128
156
  - - "~>"
@@ -136,47 +164,47 @@ dependencies:
136
164
  - !ruby/object:Gem::Version
137
165
  version: '10.0'
138
166
  - !ruby/object:Gem::Dependency
139
- name: runcom
167
+ name: sod
140
168
  requirement: !ruby/object:Gem::Requirement
141
169
  requirements:
142
170
  - - "~>"
143
171
  - !ruby/object:Gem::Version
144
- version: '9.0'
172
+ version: '0.0'
145
173
  type: :runtime
146
174
  prerelease: false
147
175
  version_requirements: !ruby/object:Gem::Requirement
148
176
  requirements:
149
177
  - - "~>"
150
178
  - !ruby/object:Gem::Version
151
- version: '9.0'
179
+ version: '0.0'
152
180
  - !ruby/object:Gem::Dependency
153
181
  name: spek
154
182
  requirement: !ruby/object:Gem::Requirement
155
183
  requirements:
156
184
  - - "~>"
157
185
  - !ruby/object:Gem::Version
158
- version: '1.0'
186
+ version: '2.0'
159
187
  type: :runtime
160
188
  prerelease: false
161
189
  version_requirements: !ruby/object:Gem::Requirement
162
190
  requirements:
163
191
  - - "~>"
164
192
  - !ruby/object:Gem::Version
165
- version: '1.0'
193
+ version: '2.0'
166
194
  - !ruby/object:Gem::Dependency
167
195
  name: versionaire
168
196
  requirement: !ruby/object:Gem::Requirement
169
197
  requirements:
170
198
  - - "~>"
171
199
  - !ruby/object:Gem::Version
172
- version: '11.0'
200
+ version: '12.0'
173
201
  type: :runtime
174
202
  prerelease: false
175
203
  version_requirements: !ruby/object:Gem::Requirement
176
204
  requirements:
177
205
  - - "~>"
178
206
  - !ruby/object:Gem::Version
179
- version: '11.0'
207
+ version: '12.0'
180
208
  - !ruby/object:Gem::Dependency
181
209
  name: zeitwerk
182
210
  requirement: !ruby/object:Gem::Requirement
@@ -205,18 +233,13 @@ files:
205
233
  - README.adoc
206
234
  - exe/milestoner
207
235
  - lib/milestoner.rb
208
- - lib/milestoner/cli/actions/config.rb
209
- - lib/milestoner/cli/actions/container.rb
210
- - lib/milestoner/cli/actions/import.rb
211
236
  - lib/milestoner/cli/actions/publish.rb
212
237
  - lib/milestoner/cli/actions/status.rb
213
- - lib/milestoner/cli/parser.rb
214
- - lib/milestoner/cli/parsers/core.rb
215
238
  - lib/milestoner/cli/shell.rb
216
239
  - lib/milestoner/commits/categorizer.rb
217
- - lib/milestoner/configuration/content.rb
240
+ - lib/milestoner/configuration/contract.rb
218
241
  - lib/milestoner/configuration/defaults.yml
219
- - lib/milestoner/configuration/loader.rb
242
+ - lib/milestoner/configuration/model.rb
220
243
  - lib/milestoner/container.rb
221
244
  - lib/milestoner/error.rb
222
245
  - lib/milestoner/import.rb
@@ -251,9 +274,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
251
274
  - !ruby/object:Gem::Version
252
275
  version: '0'
253
276
  requirements: []
254
- rubygems_version: 3.4.12
277
+ rubygems_version: 3.4.14
255
278
  signing_key:
256
279
  specification_version: 4
257
- summary: A command line interface for crafting Git semantically versioned repository
258
- tags.
280
+ summary: A command line interface for managing Git repository milestones.
259
281
  test_files: []
metadata.gz.sig CHANGED
Binary file
@@ -1,33 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Milestoner
4
- module CLI
5
- module Actions
6
- # Handles the gem configuration action.
7
- class Config
8
- include Milestoner::Import[:kernel, :logger]
9
-
10
- def initialize(configuration: Configuration::Loader::CLIENT, **)
11
- super(**)
12
- @configuration = configuration
13
- end
14
-
15
- def call action
16
- case action
17
- when :edit then edit
18
- when :view then view
19
- else logger.error { "Invalid configuration action: #{action}." }
20
- end
21
- end
22
-
23
- private
24
-
25
- attr_reader :configuration
26
-
27
- def edit = kernel.system("$EDITOR #{configuration.current}")
28
-
29
- def view = kernel.system("cat #{configuration.current}")
30
- end
31
- end
32
- end
33
- end
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "dry/container"
4
-
5
- module Milestoner
6
- module CLI
7
- module Actions
8
- # Provides a single container with application and action specific dependencies.
9
- module Container
10
- extend Dry::Container::Mixin
11
-
12
- merge Milestoner::Container
13
-
14
- register(:config) { Config.new }
15
- register(:publish) { Publish.new }
16
- register(:status) { Status.new }
17
- end
18
- end
19
- end
20
- end
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "infusible"
4
-
5
- module Milestoner
6
- module CLI
7
- module Actions
8
- Import = Infusible.with Container
9
- end
10
- end
11
- end
@@ -1,35 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "core"
4
- require "optparse"
5
-
6
- module Milestoner
7
- module CLI
8
- # Assembles and parses all Command Line Interface (CLI) options.
9
- class Parser
10
- include Import[:configuration]
11
-
12
- CLIENT = OptionParser.new nil, 40, " "
13
- SECTIONS = [Parsers::Core].freeze
14
-
15
- def initialize(sections: SECTIONS, client: CLIENT, **)
16
- super(**)
17
- @sections = sections
18
- @client = client
19
- @configuration_duplicate = configuration.dup
20
- end
21
-
22
- def call arguments = Core::EMPTY_ARRAY
23
- sections.each { |section| section.call configuration_duplicate, client: }
24
- client.parse arguments
25
- configuration_duplicate.freeze
26
- end
27
-
28
- def to_s = client.to_s
29
-
30
- private
31
-
32
- attr_reader :sections, :client, :configuration_duplicate
33
- end
34
- end
35
- end
@@ -1,81 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "core"
4
- require "refinements/structs"
5
- require "versionaire/extensions/option_parser"
6
-
7
- module Milestoner
8
- module CLI
9
- # Handles parsing of Command Line Interface (CLI) primary options.
10
- module Parsers
11
- using Refinements::Structs
12
-
13
- # Handles parsing of Command Line Interface (CLI) core options.
14
- class Core
15
- include Import[:specification]
16
-
17
- def self.call(...) = new(...).call
18
-
19
- def initialize(configuration = Container[:configuration], client: Parser::CLIENT, **)
20
- super(**)
21
- @configuration = configuration
22
- @client = client
23
- end
24
-
25
- def call arguments = ::Core::EMPTY_ARRAY
26
- client.banner = specification.labeled_summary
27
- client.separator "\nUSAGE:\n"
28
- collate
29
- client.parse arguments
30
- configuration
31
- end
32
-
33
- private
34
-
35
- attr_reader :configuration, :client
36
-
37
- def collate = private_methods.sort.grep(/add_/).each { |method| __send__ method }
38
-
39
- def add_config
40
- client.on(
41
- "-c",
42
- "--config ACTION",
43
- %i[edit view],
44
- "Manage gem configuration. Actions: edit || view."
45
- ) do |action|
46
- configuration.merge! action_config: action
47
- end
48
- end
49
-
50
- def add_publish
51
- client.on(
52
- "-P",
53
- "--publish VERSION",
54
- Versionaire::Version,
55
- "Tag and push milestone to remote repository."
56
- ) do |version|
57
- configuration.merge! action_publish: true, version:
58
- end
59
- end
60
-
61
- def add_status
62
- client.on "-s", "--status", "Show project status." do
63
- configuration.merge! action_status: true
64
- end
65
- end
66
-
67
- def add_version
68
- client.on "-v", "--version", "Show gem version." do
69
- configuration.merge! action_version: true
70
- end
71
- end
72
-
73
- def add_help
74
- client.on "-h", "--help", "Show this message." do
75
- configuration.merge! action_help: true
76
- end
77
- end
78
- end
79
- end
80
- end
81
- end
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Milestoner
4
- module Configuration
5
- # Defines configuration content as the primary source of truth for use throughout the gem.
6
- Content = Struct.new(
7
- :action_config,
8
- :action_publish,
9
- :action_push,
10
- :action_status,
11
- :action_tag,
12
- :action_version,
13
- :action_help,
14
- :documentation_format,
15
- :prefixes,
16
- :version,
17
- keyword_init: true
18
- ) do
19
- def initialize *arguments
20
- super
21
- freeze
22
- end
23
- end
24
- end
25
- end
@@ -1,35 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "pathname"
4
- require "refinements/hashes"
5
- require "refinements/structs"
6
- require "runcom"
7
- require "yaml"
8
-
9
- module Milestoner
10
- module Configuration
11
- # Represents the fully assembled Command Line Interface (CLI) configuration.
12
- class Loader
13
- using Refinements::Hashes
14
- using Refinements::Structs
15
-
16
- DEFAULTS = YAML.load_file(Pathname(__dir__).join("defaults.yml")).freeze
17
- CLIENT = Runcom::Config.new "milestoner/configuration.yml", defaults: DEFAULTS
18
-
19
- def self.call = new.call
20
-
21
- def self.with_defaults = new(client: DEFAULTS)
22
-
23
- def initialize content: Content.new, client: CLIENT
24
- @content = content
25
- @client = client
26
- end
27
-
28
- def call = content.merge(**client.to_h.flatten_keys)
29
-
30
- private
31
-
32
- attr_reader :content, :client
33
- end
34
- end
35
- end