Merge pull request #6537 from cli/hyperlink-helper-docs

Document the hyperlink helper
This commit is contained in:
Mislav Marohnić 2022-11-01 19:34:03 +01:00 committed by GitHub
commit 0d77e9e945
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -121,6 +121,7 @@ var HelpTopics = map[string]map[string]string{
- %[1]stimeago <time>%[1]s: renders a timestamp as relative to now
- %[1]stimefmt <format> <time>%[1]s: formats a timestamp using Go's Time.Format function
- %[1]struncate <length> <input>%[1]s: ensures input fits within length
- %[1]shyperlink <url> <text>%[1]s: renders a terminal hyperlink
To learn more about Go templates, see: <https://golang.org/pkg/text/template/>.
`, "`"),
@ -168,6 +169,10 @@ var HelpTopics = map[string]map[string]string{
cli-maintainer
# using the --template flag with the hyperlink helper
gh issue list --json title,url --template '{{range .}}{{hyperlink .url .title}}{{"\n"}}{{end}}'
# adding the --template flag and modifying the display format
$ gh pr list --json number,title,headRefName,updatedAt --template \
'{{range .}}{{tablerow (printf "#%v" .number | autocolor "green") .title .headRefName (timeago .updatedAt)}}{{end}}'