1
+ // Package termlink implements a set of functions to create customizable, clickable hyperlinks in the terminal.
1
2
package termlink
2
3
3
4
import (
@@ -136,12 +137,14 @@ func supportsColor() bool {
136
137
return supportscolor .Stdout ().SupportsColor
137
138
}
138
139
139
- /**
140
- * @info Create a clickable link in the terminal's stdout.
141
- * @param {string} [text] The text to be displayed.
142
- * @param {string} [url] The URL to be opened when the link is clicked.
143
- * @returns {string} The clickable link.
144
- */
140
+ // Function Link creates a clickable link in the terminal's stdout.
141
+ //
142
+ // The function takes two parameters: text and url.
143
+ //
144
+ // The text parameter is the text to be displayed.
145
+ // The url parameter is the URL to be opened when the link is clicked.
146
+ //
147
+ // The function returns the clickable link.
145
148
func Link (text string , url string ) string {
146
149
if supportsHyperlinks () {
147
150
return "\x1b ]8;;" + url + "\x07 " + text + "\x1b ]8;;\x07 " + parseColor ("reset" )
@@ -150,13 +153,15 @@ func Link(text string, url string) string {
150
153
}
151
154
}
152
155
153
- /**
154
- * @info Create a clickable link in the terminal's stdout.
155
- * @param {string} [text] The text to be displayed.
156
- * @param {string} [url] The URL to be opened when the link is clicked.
157
- * @param {string} [color] The color of the link.
158
- * @returns {string} The clickable link.
159
- */
156
+ // Function LinkColor creates a colored clickable link in the terminal's stdout.
157
+ //
158
+ // The function takes three parameters: text, url and color.
159
+ //
160
+ // The text parameter is the text to be displayed.
161
+ // The url parameter is the URL to be opened when the link is clicked.
162
+ // The color parameter is the color of the link.
163
+ //
164
+ // The function returns the clickable link.
160
165
func ColorLink (text string , url string , color string ) string {
161
166
var textColor string
162
167
@@ -172,7 +177,9 @@ func ColorLink(text string, url string, color string) string {
172
177
}
173
178
}
174
179
175
- // export supportsHyperlinks to be used in testing
180
+ // Function SupportsHyperlinks returns true if the terminal supports hyperlinks.
181
+ //
182
+ // The function returns true if the terminal supports hyperlinks, false otherwise.
176
183
func SupportsHyperlinks () bool {
177
184
return supportsHyperlinks ()
178
185
}
0 commit comments