Skip to content

Commit 3fe5033

Browse files
justin808claude
andauthored
Fix bin/dev --verbose option causing error (#2023)
## Summary - Implements the `--verbose`/`-v` flag that was documented but not functional - Fixes OptionParser to properly handle the verbose flag - Updates all start() calls to pass through the verbose option ## What was the problem? The `--verbose` option was shown in `bin/dev --help` output but caused an `OptionParser::InvalidOption` error when used. This happened because: 1. The help text documented `--verbose, -v` 2. The `start()` method accepted a `verbose:` parameter 3. But the OptionParser in `run_from_command_line()` didn't parse the flag 4. All calls to `start()` hardcoded `verbose: false` ## Changes - Added `verbose: false` to the options hash initialization - Implemented `--verbose`/`-v` flag parsing in OptionParser - Updated three `start()` calls to use `options[:verbose]` instead of hardcoded `false` - Added RuboCop disable/enable comments for AbcSize metric (slightly increased by parameter handling) ## Test Plan - ✅ Manually tested `--verbose` and `-v` flags with all commands - ✅ All existing RSpec tests pass - ✅ RuboCop passes with no violations - ✅ Pre-commit and pre-push hooks pass ## Testing ```bash # All of these now work without error: bin/dev --verbose bin/dev -v bin/dev static --verbose bin/dev prod -v ``` Closes #1849 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- Reviewable:start --> - - - This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/shakacode/react_on_rails/2023) <!-- Reviewable:end --> Co-authored-by: Claude <noreply@anthropic.com>
1 parent cf005af commit 3fe5033

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

lib/react_on_rails/dev/server_manager.rb

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,11 @@ def show_help
144144
puts help_troubleshooting
145145
end
146146

147+
# rubocop:disable Metrics/AbcSize
147148
def run_from_command_line(args = ARGV)
148149
require "optparse"
149150

150-
options = { route: nil, rails_env: nil }
151+
options = { route: nil, rails_env: nil, verbose: false }
151152

152153
OptionParser.new do |opts|
153154
opts.banner = "Usage: dev [command] [options]"
@@ -160,6 +161,10 @@ def run_from_command_line(args = ARGV)
160161
options[:rails_env] = env
161162
end
162163

164+
opts.on("-v", "--verbose", "Enable verbose output for pack generation") do
165+
options[:verbose] = true
166+
end
167+
163168
opts.on("-h", "--help", "Prints this help") do
164169
show_help
165170
exit
@@ -172,21 +177,23 @@ def run_from_command_line(args = ARGV)
172177
# Main execution
173178
case command
174179
when "production-assets", "prod"
175-
start(:production_like, nil, verbose: false, route: options[:route], rails_env: options[:rails_env])
180+
start(:production_like, nil, verbose: options[:verbose], route: options[:route],
181+
rails_env: options[:rails_env])
176182
when "static"
177-
start(:static, "Procfile.dev-static-assets", verbose: false, route: options[:route])
183+
start(:static, "Procfile.dev-static-assets", verbose: options[:verbose], route: options[:route])
178184
when "kill"
179185
kill_processes
180186
when "help", "--help", "-h"
181187
show_help
182188
when "hmr", nil
183-
start(:development, "Procfile.dev", verbose: false, route: options[:route])
189+
start(:development, "Procfile.dev", verbose: options[:verbose], route: options[:route])
184190
else
185191
puts "Unknown argument: #{command}"
186192
puts "Run 'dev help' for usage information"
187193
exit 1
188194
end
189195
end
196+
# rubocop:enable Metrics/AbcSize
190197

191198
private
192199

0 commit comments

Comments
 (0)