Skip to content

Commit 5f171ba

Browse files
authored
feat: add --host and --ui_host flags to install command (#584)
1 parent 5b32b23 commit 5f171ba

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

lib/honeybadger/cli/install.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ def run
7878
insights:
7979
enabled: #{options["insights"]}
8080
CONFIG
81+
if (connection = options.slice("host", "ui_host")).any?
82+
file.puts("\n# Override hosts\nconnection:")
83+
connection.each {|k,v| file.puts(" #{k}: '#{v}'") }
84+
end
8185
end
8286
end
8387

lib/honeybadger/cli/main.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ def help(*args, &block)
4949

5050
desc 'install API_KEY', 'Install Honeybadger into a new project'
5151
option :insights, type: :boolean, aliases: :'-i', default: false, desc: 'Enable Honeybadger Insights'
52+
option :host, type: :string
53+
option :ui_host, type: :string
5254
def install(api_key)
5355
Install.new(options, api_key).run
5456
rescue => e

spec/features/install_spec.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,26 @@
5151
expect(YAML.load_file(config_file).dig("insights", "enabled")).to eq(false)
5252
end
5353
end
54+
55+
context "with host and/or UI host flags" do
56+
let(:yaml) { YAML.load_file(config_file) }
57+
58+
it "configures the host" do
59+
run_command_and_stop('honeybadger install asdf --host api.honeybadger.io', fail_on_error: true)
60+
expect(yaml.dig("connection", "host")).to eq('api.honeybadger.io')
61+
end
62+
63+
it "configures the UI host" do
64+
run_command_and_stop('honeybadger install asdf --ui_host app.honeybadger.io', fail_on_error: true)
65+
expect(yaml.dig("connection", "ui_host")).to eq('app.honeybadger.io')
66+
end
67+
68+
it "configures both hosts" do
69+
run_command_and_stop('honeybadger install asdf --host api.honeybadger.io --ui_host app.honeybadger.io', fail_on_error: true)
70+
expect(yaml.dig("connection", "host")).to eq('api.honeybadger.io')
71+
expect(yaml.dig("connection", "ui_host")).to eq('app.honeybadger.io')
72+
end
73+
end
5474

5575
scenario "when the configuration file already exists" do
5676
before { File.write(config_file, <<-YML) }

0 commit comments

Comments
 (0)