Skip to content

Commit d2907a0

Browse files
committed
Add Options class and switch Application to use it instead of anonymous Struct for CLI options
1 parent 68020a7 commit d2907a0

File tree

3 files changed

+34
-7
lines changed

3 files changed

+34
-7
lines changed

lib/rake.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ module Rake; end
4343
require_relative "rake/rake_module"
4444
require_relative "rake/trace_output"
4545
require_relative "rake/pseudo_status"
46+
require_relative "rake/options"
4647
require_relative "rake/task_arguments"
4748
require_relative "rake/invocation_chain"
4849
require_relative "rake/task"

lib/rake/application.rb

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# frozen_string_literal: true
22
require "optparse"
33

4+
require_relative "options"
45
require_relative "task_manager"
56
require_relative "file_list"
67
require_relative "thread_pool"
@@ -165,13 +166,7 @@ def add_loader(ext, loader)
165166

166167
# Application options from the command line
167168
def options
168-
@options ||= Struct.new(
169-
:always_multitask, :backtrace, :build_all, :dryrun,
170-
:ignore_deprecate, :ignore_system, :job_stats, :load_system,
171-
:nosearch, :rakelib, :show_all_tasks, :show_prereqs,
172-
:show_task_pattern, :show_tasks, :silent, :suppress_backtrace_pattern,
173-
:thread_pool_size, :trace, :trace_output, :trace_rules
174-
).new
169+
@options ||= Options.new
175170
end
176171

177172
# Return the thread pool used for multithreaded processing.

lib/rake/options.rb

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# frozen_string_literal: true
2+
3+
module Rake
4+
5+
##
6+
# Options used by the Rake command line application.
7+
#
8+
class Options
9+
attr_accessor :always_multitask
10+
attr_accessor :backtrace
11+
attr_accessor :build_all
12+
attr_accessor :dryrun
13+
attr_accessor :ignore_deprecate
14+
attr_accessor :ignore_system
15+
attr_accessor :job_stats
16+
attr_accessor :load_system
17+
attr_accessor :nosearch
18+
attr_accessor :rakelib
19+
attr_accessor :show_all_tasks
20+
attr_accessor :show_prereqs
21+
attr_accessor :show_task_pattern
22+
attr_accessor :show_tasks
23+
attr_accessor :silent
24+
attr_accessor :suppress_backtrace_pattern
25+
attr_accessor :thread_pool_size
26+
attr_accessor :trace
27+
attr_accessor :trace_output
28+
attr_accessor :trace_rules
29+
end
30+
31+
end

0 commit comments

Comments
 (0)