Skip to content

Commit 2ac225f

Browse files
hsbtclaude
andcommitted
Wire the --cooldown flag through one method
Each of the five commands that take the flag validated it and set it as a command option itself, and install read it under a string key while the rest used a symbol. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent c6b3a60 commit 2ac225f

6 files changed

Lines changed: 15 additions & 10 deletions

File tree

lib/bundler/cli/add.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ def initialize(options, gems)
1414
def run
1515
Bundler.ui.level = "warn" if options[:quiet]
1616

17-
Bundler::CLI::Common.validate_cooldown!(options[:cooldown])
18-
Bundler.settings.set_command_option_if_given :cooldown, options[:cooldown]
17+
Bundler::CLI::Common.configure_cooldown(options)
1918

2019
validate_options!
2120
inject_dependencies

lib/bundler/cli/common.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22

33
module Bundler
44
module CLI::Common
5+
# Validates the `--cooldown` flag and makes it the setting for this
6+
# command. Every command that takes the flag goes through here, so they
7+
# share one reading of the value.
8+
def self.configure_cooldown(options)
9+
value = options[:cooldown]
10+
11+
validate_cooldown!(value)
12+
Bundler.settings.set_command_option_if_given :cooldown, value
13+
end
14+
515
def self.validate_cooldown!(value)
616
# Without the flag the config file and BUNDLE_COOLDOWN decide, and those
717
# only warn, so a typo left in a config file keeps the command usable.

lib/bundler/cli/install.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,7 @@ def normalize_settings
115115

116116
Bundler.settings.set_command_option_if_given :jobs, options["jobs"]
117117

118-
Bundler::CLI::Common.validate_cooldown!(options["cooldown"])
119-
Bundler.settings.set_command_option_if_given :cooldown, options["cooldown"]
118+
Bundler::CLI::Common.configure_cooldown(options)
120119

121120
Bundler.settings.set_command_option_if_given :no_install, options["no-install"]
122121

lib/bundler/cli/lock.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ def run
1616

1717
check_for_conflicting_options
1818

19-
Bundler::CLI::Common.validate_cooldown!(options[:cooldown])
20-
Bundler.settings.set_command_option_if_given :cooldown, options[:cooldown]
19+
Bundler::CLI::Common.configure_cooldown(options)
2120

2221
print = options[:print]
2322
previous_output_stream = Bundler.ui.output_stream

lib/bundler/cli/outdated.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ def initialize(options, gems)
2626
def run
2727
check_for_deployment_mode!
2828

29-
Bundler::CLI::Common.validate_cooldown!(options[:cooldown])
30-
Bundler.settings.set_command_option_if_given :cooldown, options[:cooldown]
29+
Bundler::CLI::Common.configure_cooldown(options)
3130

3231
Bundler.definition.validate_runtime!
3332
current_specs = Bundler.ui.silence { Bundler.definition.resolve }

lib/bundler/cli/update.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ def run
7474
opts["force"] = options[:redownload] if options[:redownload]
7575

7676
Bundler.settings.set_command_option_if_given :jobs, opts["jobs"]
77-
Bundler::CLI::Common.validate_cooldown!(options[:cooldown])
78-
Bundler.settings.set_command_option_if_given :cooldown, options[:cooldown]
77+
Bundler::CLI::Common.configure_cooldown(options)
7978

8079
Bundler.definition.validate_runtime!
8180

0 commit comments

Comments
 (0)