diff --git a/src/effects/fix.rs b/src/effects/fix.rs index e3b4f367..42d4fb00 100644 --- a/src/effects/fix.rs +++ b/src/effects/fix.rs @@ -29,7 +29,7 @@ pub fn run(ctx: Context) -> Context { let location = ui.instance_location(instance).dimmed(); let state = instance.state.borrow().clone(); let state_name = state.get_name(); - let state_link = ui.status_code_link(&state_name); + let state_link = ui.instance_status_code_link(&state_name); let state_link = format!("({state_link})").dimmed(); match state { diff --git a/src/effects/ui.rs b/src/effects/ui.rs index 9dd046df..7e4c2845 100644 --- a/src/effects/ui.rs +++ b/src/effects/ui.rs @@ -59,7 +59,7 @@ impl<'a> Ui<'a> { }) .sorted() .unique() - .map(|state_name| self.status_code_link(&state_name)) + .map(|state_name| self.instance_status_code_link(&state_name)) .join(", "); let state_links = if !state_links.is_empty() { format!("({state_links})").dimmed() @@ -263,7 +263,7 @@ impl<'a> Ui<'a> { } else { state_name.normal() }; - let state_link = self.status_code_link(&state_name); + let state_link = self.instance_status_code_link(&state_name); let state_link = if !state_link.is_empty() { format!("({state_link})").dimmed() } else { @@ -521,10 +521,17 @@ impl<'a> Ui<'a> { format!("{plain_link}").normal() } - pub fn status_code_link(&self, pascal_case: &str) -> ColoredString { - if !self.ctx.config.cli.options.show_status_codes { - return "".normal(); + /// If enabled, render the reason code as a clickable link + pub fn instance_status_code_link(&self, pascal_case: &str) -> ColoredString { + if self.ctx.config.cli.options.show_status_codes { + self.status_code_link(pascal_case) + } else { + "".normal() } + } + + /// Render the reason code as a clickable link + fn status_code_link(&self, pascal_case: &str) -> ColoredString { let base_url = "https://jamiemason.github.io/syncpack/guide/status-codes/"; let lower_case = pascal_case.to_lowercase(); let plain_link = self.link(format!("{base_url}#{lower_case}"), pascal_case);