diff options
author | Dan Davison <dandavison7@gmail.com> | 2020-07-18 15:34:43 -0400 |
---|---|---|
committer | Dan Davison <dandavison7@gmail.com> | 2020-07-22 17:57:57 -0400 |
commit | b2257cfae7eacc73e47299d90d9a8d479b3e362c (patch) | |
tree | 56b60ad41ce689042ce64c4793eec35100d8c322 /src/format.rs | |
parent | 29bf022218f72157e1921412ae6ede598733b6fb (diff) |
Format files and commits as OSC 8 hyperlinks
Closes #257
Diffstat (limited to 'src/format.rs')
-rw-r--r-- | src/format.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/format.rs b/src/format.rs new file mode 100644 index 00000000..ed368c0d --- /dev/null +++ b/src/format.rs @@ -0,0 +1,16 @@ +use std::borrow::Cow; + +use atty; + +use crate::config::Config; +use crate::features; + +/// If output is going to a tty, emit hyperlinks if requested. +// Although raw output should basically be emitted unaltered, we do this. +pub fn format_raw_line<'a>(line: &'a str, config: &Config) -> Cow<'a, str> { + if config.hyperlinks && atty::is(atty::Stream::Stdout) { + features::hyperlinks::format_commit_line_with_osc8_commit_hyperlink(line, config) + } else { + Cow::from(line) + } +} |