diff --git a/lib/yard/cli/server.rb b/lib/yard/cli/server.rb index 65b17915e..f5bfc3b11 100644 --- a/lib/yard/cli/server.rb +++ b/lib/yard/cli/server.rb @@ -181,6 +181,9 @@ def optparse(*args) opts.on('-d', '--daemon', 'Daemonizes the server process') do server_options[:daemonize] = true end + opts.on('-B HOST', '--bind', 'The host address to bind to') do |host| + server_options[:Host] = host.to_s + end opts.on('-p PORT', '--port', 'Serves documentation on PORT') do |port| server_options[:Port] = port.to_i end diff --git a/spec/cli/server_spec.rb b/spec/cli/server_spec.rb index d0b91cd88..f2211ce17 100644 --- a/spec/cli/server_spec.rb +++ b/spec/cli/server_spec.rb @@ -173,6 +173,24 @@ def mock_file(filename, content = nil) run '--daemon' end + it "should accept -B, --bind" do + @server_options[:Host] = 'example.com' + run '-B', 'example.com' + run '--bind', 'example.com' + end + + it "should bind address with WebRick adapter" do + @server_options[:Host] = 'example.com' + run '-B', 'example.com', '-a', 'webrick' + run '--bind', 'example.com', '-a', 'webrick' + end + + it "should bind address with Rack adapter" do + @server_options[:Host] = 'example.com' + run '-B', 'example.com', '-a', 'rack' + run '--bind', 'example.com', '-a', 'rack' + end + it "should accept -p, --port" do @server_options[:Port] = 10 run '-p', '10'