Crates.io | unfurl |
lib.rs | unfurl |
version | 0.3.0 |
source | src |
created_at | 2023-11-09 04:07:56.596468 |
updated_at | 2023-12-02 02:04:55.754548 |
description | A tool for expanding links in text |
homepage | |
repository | https://github.com/bww/unfurl |
max_upload_size | |
id | 1029785 |
size | 68,903 |
Unfurl expands links in text and replaces them with useful content.
$ unfurl <<EOF
This issue was resolved: https://github.com/bww/unfurl/issues/1
EOF
This issue was resolved: This is just an example issue (#1)
$
Unfurl supports expanding the following URL types out of the box:
Github
https://api.github.com/repos/{org}/{repo}/pulls/{num}'
https://api.github.com/repos/{org}/{repo}/issues/{num}
Jira Cloud
https://{domain}/rest/api/3/issue/{key}
You can add support for more services by configuring a routes definition and specifying it on the command line via --routes <definition.yml>
. The built-in routes definition file can be used as reference. Custom routes are appended to the built-in routes and take prescidence.
The general notion is that Unfurl matches a presentation/browser URL, converts it to an API counterpart (or perhaps just provides suitable headers to the same URL) which represents the same information in a structured form. Then a default format determines how that structured data is rendered into text. The following is illustrative:
github.com:
routes:
- name: pr
route: "/{org}/{repo}/pull/{num}"
url: "https://api.github.com/repos/{org}/{repo}/pulls/{num}"
format: "{title} (PR #{number})"
routes.yml
Out of the box, Unfurl will work as expected for supported public URLs. Often, however, URLs hosted on these services are not public, so you may need to provide some credentials. This can be done via a configuration file, located by default at $HOME/.unfurl.yml
.
It is also possible to specify how, exactly, URLs are expanded by defining a per-URL formatting template. The input to this format is the JSON received from the underlying service, so you can use any information that is made available through the service's APIs.
services:
# We provide authentication and custom formatting for GitHub routes. You
# cannot define routes in a configuration file, use a route definition
# file for that.
github.com:
auth: # optionally provide authentication to expand non-public URLs
header: Bearer $YOUR_PERSONAL_ACCESS_TOKEN
format: # optionally define formats for these URL patterns
pr: "[{number}] {title} ({url})"
issue: "[{number}] {title} ({url})"
# Jira configurations are per-cloud-tenant: specify your domain. (Unfurl
# will fail over to the base domain, `atlassian.net` in this case, if no
# exact match is found.)
treno.atlassian.net:
auth:
header: Basic $YOUR_PERSONAL_ACCESS_CREDENTIALS
format:
issue: "[{key}] {fields.summary}"
# And so on for whatever other domains you have added...
twitter.com:
auth:
header: # ...
$HOME/.unfurl.yml