From d2907a0adb9bf992e76e7494c64d77cc3b2fa70c Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Fri, 6 Feb 2026 11:34:42 +0900 Subject: [PATCH] Add Options class and switch Application to use it instead of anonymous Struct for CLI options --- lib/rake.rb | 1 + lib/rake/application.rb | 9 ++------- lib/rake/options.rb | 31 +++++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 7 deletions(-) create mode 100644 lib/rake/options.rb diff --git a/lib/rake.rb b/lib/rake.rb index 2006fbad9..f1c6f299d 100644 --- a/lib/rake.rb +++ b/lib/rake.rb @@ -43,6 +43,7 @@ module Rake; end require_relative "rake/rake_module" require_relative "rake/trace_output" require_relative "rake/pseudo_status" +require_relative "rake/options" require_relative "rake/task_arguments" require_relative "rake/invocation_chain" require_relative "rake/task" diff --git a/lib/rake/application.rb b/lib/rake/application.rb index 87ae47b32..5694cb345 100644 --- a/lib/rake/application.rb +++ b/lib/rake/application.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require "optparse" +require_relative "options" require_relative "task_manager" require_relative "file_list" require_relative "thread_pool" @@ -165,13 +166,7 @@ def add_loader(ext, loader) # Application options from the command line def options - @options ||= Struct.new( - :always_multitask, :backtrace, :build_all, :dryrun, - :ignore_deprecate, :ignore_system, :job_stats, :load_system, - :nosearch, :rakelib, :show_all_tasks, :show_prereqs, - :show_task_pattern, :show_tasks, :silent, :suppress_backtrace_pattern, - :thread_pool_size, :trace, :trace_output, :trace_rules - ).new + @options ||= Options.new end # Return the thread pool used for multithreaded processing. diff --git a/lib/rake/options.rb b/lib/rake/options.rb new file mode 100644 index 000000000..01974c5bf --- /dev/null +++ b/lib/rake/options.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +module Rake + + ## + # Options used by the Rake command line application. + # + class Options + attr_accessor :always_multitask + attr_accessor :backtrace + attr_accessor :build_all + attr_accessor :dryrun + attr_accessor :ignore_deprecate + attr_accessor :ignore_system + attr_accessor :job_stats + attr_accessor :load_system + attr_accessor :nosearch + attr_accessor :rakelib + attr_accessor :show_all_tasks + attr_accessor :show_prereqs + attr_accessor :show_task_pattern + attr_accessor :show_tasks + attr_accessor :silent + attr_accessor :suppress_backtrace_pattern + attr_accessor :thread_pool_size + attr_accessor :trace + attr_accessor :trace_output + attr_accessor :trace_rules + end + +end