about summary refs log tree commit diff
path: root/internal/terminal
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2024-03-20 19:00:15 -0700
committerFranck Cuny <franck@fcuny.net>2024-03-20 19:03:03 -0700
commit496ee376a75798f2a1af247e6934138cad0a84e2 (patch)
tree94528bf55ae2552ee47bd61cf35239c07b092d56 /internal/terminal
parentchore: update flake (diff)
downloadworld-496ee376a75798f2a1af247e6934138cad0a84e2.tar.gz
`ghalogs` get the logs of a GHA workflow run
Add a few internal packages to get the root of the git repository and to
create clickable links in the terminal.
Diffstat (limited to 'internal/terminal')
-rw-r--r--internal/terminal/link.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/internal/terminal/link.go b/internal/terminal/link.go
new file mode 100644
index 0000000..a50b199
--- /dev/null
+++ b/internal/terminal/link.go
@@ -0,0 +1,13 @@
+package terminal
+
+import "fmt"
+
+// Link returns a formatted string that represents a hyperlink.
+// The hyperlink is created using the escape sequence for terminal emulators.
+// The text parameter represents the visible text of the hyperlink,
+// and the url parameter represents the URL that the hyperlink points to.
+// For more information on the escape sequence, refer to:
+// https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda#the-escape-sequence
+func Link(text string, url string) string {
+	return fmt.Sprintf("\x1b]8;;%s\x07%s\x1b]8;;\x07\u001b[0m", url, text)
+}