From 59079c53ddc87bd9dae3d07d99c9dfe164f5ee64 Mon Sep 17 00:00:00 2001 From: Lucas Himschoot <34957838+WatermelonArray@users.noreply.github.com> Date: Tue, 14 Jun 2022 12:57:02 +0100 Subject: [PATCH 1/5] Added address reference to CLI output --- src/cli/serve.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/cli/serve.rs b/src/cli/serve.rs index 9d2aa3434..f6fe7f27d 100644 --- a/src/cli/serve.rs +++ b/src/cli/serve.rs @@ -88,7 +88,14 @@ fn show_start_message(bind_address: IpAddr, port: u16, color: ColorChoice) -> io write!(&mut buffer, "Visit ")?; buffer.set_color(&green)?; - write!(&mut buffer, "http://localhost:{}/", port)?; + if bind_address.is_loopback() { + write!(&mut buffer, "http://localhost:")?; + } else { + write!(&mut buffer, "http://{}:", bind_address)?; + } + + buffer.set_color(&green)?; + write!(&mut buffer, "{}/", port)?; buffer.set_color(&ColorSpec::new())?; writeln!(&mut buffer, " in your browser for more information.")?; From bc13a0d2387ef9de5361f894a126499ec41d1ebc Mon Sep 17 00:00:00 2001 From: Lucas Himschoot <34957838+WatermelonArray@users.noreply.github.com> Date: Tue, 14 Jun 2022 13:46:51 +0100 Subject: [PATCH 2/5] Stored loopback check address as a variable --- src/cli/serve.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/cli/serve.rs b/src/cli/serve.rs index f6fe7f27d..d3dc6e58d 100644 --- a/src/cli/serve.rs +++ b/src/cli/serve.rs @@ -66,6 +66,8 @@ fn show_start_message(bind_address: IpAddr, port: u16, color: ColorChoice) -> io let writer = BufferWriter::stdout(color); let mut buffer = writer.buffer(); + + let address_string = if bind_address.is_loopback() {"localhost"} else {stringify!(bind_address)}; writeln!(&mut buffer, "Rojo server listening:")?; @@ -88,11 +90,7 @@ fn show_start_message(bind_address: IpAddr, port: u16, color: ColorChoice) -> io write!(&mut buffer, "Visit ")?; buffer.set_color(&green)?; - if bind_address.is_loopback() { - write!(&mut buffer, "http://localhost:")?; - } else { - write!(&mut buffer, "http://{}:", bind_address)?; - } + write!(&mut buffer, "http://{}:", address_string)?; buffer.set_color(&green)?; write!(&mut buffer, "{}/", port)?; From 9f72a5bbee9838f320241d7d7b787f65f03cab65 Mon Sep 17 00:00:00 2001 From: Lucas Himschoot <34957838+WatermelonArray@users.noreply.github.com> Date: Tue, 14 Jun 2022 13:49:47 +0100 Subject: [PATCH 3/5] Changed other loopback references to the new variable --- src/cli/serve.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/cli/serve.rs b/src/cli/serve.rs index d3dc6e58d..0c954555f 100644 --- a/src/cli/serve.rs +++ b/src/cli/serve.rs @@ -73,11 +73,7 @@ fn show_start_message(bind_address: IpAddr, port: u16, color: ColorChoice) -> io write!(&mut buffer, " Address: ")?; buffer.set_color(&green)?; - if bind_address.is_loopback() { - writeln!(&mut buffer, "localhost")?; - } else { - writeln!(&mut buffer, "{}", bind_address)?; - } + writeln!(&mut buffer, "{}", address_string)?; buffer.set_color(&ColorSpec::new())?; write!(&mut buffer, " Port: ")?; From 05d655af2aabd21b9c06464d7ae38c70493d72cd Mon Sep 17 00:00:00 2001 From: Lucas Himschoot <34957838+WatermelonArray@users.noreply.github.com> Date: Tue, 14 Jun 2022 14:04:29 +0100 Subject: [PATCH 4/5] Fixed mistake on address_string variable --- src/cli/serve.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/cli/serve.rs b/src/cli/serve.rs index 0c954555f..33f2b4e86 100644 --- a/src/cli/serve.rs +++ b/src/cli/serve.rs @@ -66,8 +66,12 @@ fn show_start_message(bind_address: IpAddr, port: u16, color: ColorChoice) -> io let writer = BufferWriter::stdout(color); let mut buffer = writer.buffer(); - - let address_string = if bind_address.is_loopback() {"localhost"} else {stringify!(bind_address)}; + + let address_string = if bind_address.is_loopback() { + "localhost".to_owned() + } else { + bind_address.to_string() + }; writeln!(&mut buffer, "Rojo server listening:")?; From ab2f8f020f3601b7df9d9bb3041223b2f53923d1 Mon Sep 17 00:00:00 2001 From: Lucien Greathouse Date: Wed, 29 Jun 2022 18:55:28 -0400 Subject: [PATCH 5/5] Merge write calls --- src/cli/serve.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/cli/serve.rs b/src/cli/serve.rs index 33f2b4e86..0e35785e3 100644 --- a/src/cli/serve.rs +++ b/src/cli/serve.rs @@ -90,10 +90,7 @@ fn show_start_message(bind_address: IpAddr, port: u16, color: ColorChoice) -> io write!(&mut buffer, "Visit ")?; buffer.set_color(&green)?; - write!(&mut buffer, "http://{}:", address_string)?; - - buffer.set_color(&green)?; - write!(&mut buffer, "{}/", port)?; + write!(&mut buffer, "http://{}:{}/", address_string, port)?; buffer.set_color(&ColorSpec::new())?; writeln!(&mut buffer, " in your browser for more information.")?;