Move the hyperlink escape codes into a function
This commit is contained in:
parent
054d66bf9c
commit
086dbb8af0
4 changed files with 13 additions and 6 deletions
|
@ -1,5 +1,6 @@
|
|||
use crate::cli::FormatMode;
|
||||
use crate::jira_config::JiraConfig;
|
||||
use crate::term::hyperlink;
|
||||
use crate::types::issue::JiraIssue;
|
||||
use crossterm::style::{Color, Stylize};
|
||||
use std::io::Write;
|
||||
|
@ -99,9 +100,11 @@ fn pretty_print(issue: &JiraIssue) -> Result<(), Box<dyn std::error::Error>> {
|
|||
}
|
||||
println!("\n== Actions {:=<69}", "");
|
||||
println!(
|
||||
"\u{1b}]8;;{}\u{7}{}\u{1b}]8;;\u{7}",
|
||||
issue.href,
|
||||
"Open Issue".green().underline(Color::Green)
|
||||
"{}",
|
||||
hyperlink(
|
||||
&issue.href,
|
||||
&"Open Issue".green().underline(Color::Green).to_string()
|
||||
)
|
||||
);
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -2,6 +2,7 @@ mod cli;
|
|||
mod cmd;
|
||||
mod jira_config;
|
||||
mod jql;
|
||||
mod term;
|
||||
mod types;
|
||||
|
||||
use clap::Parser;
|
||||
|
|
3
src/term.rs
Normal file
3
src/term.rs
Normal file
|
@ -0,0 +1,3 @@
|
|||
pub fn hyperlink(url: &str, text: &str) -> String {
|
||||
format!("\u{1b}]8;;{}\u{7}{}\u{1b}]8;;\u{7}", url, text)
|
||||
}
|
|
@ -1,3 +1,4 @@
|
|||
use crate::term::hyperlink;
|
||||
use crossterm::style::Stylize;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::io::Write;
|
||||
|
@ -107,9 +108,8 @@ pub fn display_issues_pretty(issues: &[JiraIssue]) -> Result<(), Box<dyn std::er
|
|||
)?;
|
||||
writeln!(
|
||||
tw,
|
||||
"\u{1b}]8;;{}\u{7}{}\u{1b}]8;;\u{7}",
|
||||
issue.href,
|
||||
"Open Issue".green()
|
||||
"{}",
|
||||
&hyperlink(&issue.href, &"Open Issue".green().to_string())
|
||||
)?;
|
||||
|
||||
tw.flush().unwrap();
|
||||
|
|
Loading…
Reference in a new issue