summaryrefslogtreecommitdiff
path: root/src/exercise.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/exercise.rs')
-rw-r--r--src/exercise.rs28
1 files changed, 2 insertions, 26 deletions
diff --git a/src/exercise.rs b/src/exercise.rs
index 4493a57..45ac208 100644
--- a/src/exercise.rs
+++ b/src/exercise.rs
@@ -2,33 +2,11 @@ use anyhow::{Context, Result};
use crossterm::style::{style, StyledContent, Stylize};
use std::{
fmt::{self, Display, Formatter},
- fs,
path::Path,
process::{Command, Output},
};
-use crate::{info_file::Mode, DEBUG_PROFILE};
-
-pub struct TerminalFileLink<'a> {
- path: &'a str,
-}
-
-impl<'a> Display for TerminalFileLink<'a> {
- fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
- if let Ok(Some(canonical_path)) = fs::canonicalize(self.path)
- .as_deref()
- .map(|path| path.to_str())
- {
- write!(
- f,
- "\x1b]8;;file://{}\x1b\\{}\x1b]8;;\x1b\\",
- canonical_path, self.path,
- )
- } else {
- write!(f, "{}", self.path,)
- }
- }
-}
+use crate::{info_file::Mode, terminal_link::TerminalFileLink, DEBUG_PROFILE};
pub struct Exercise {
pub dir: Option<&'static str>,
@@ -85,9 +63,7 @@ impl Exercise {
}
pub fn terminal_link(&self) -> StyledContent<TerminalFileLink<'_>> {
- style(TerminalFileLink { path: self.path })
- .underlined()
- .blue()
+ style(TerminalFileLink(self.path)).underlined().blue()
}
}