Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Clickable Template Links in Terminal azd template list #2845

Merged
merged 15 commits into from
Oct 11, 2023
20 changes: 16 additions & 4 deletions cli/azd/cmd/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"errors"
"fmt"
"io"
"log"
"net/http"

"github.com/azure/azure-dev/cli/azd/cmd/actions"
Expand Down Expand Up @@ -125,19 +126,30 @@ func (tl *templateListAction) Run(ctx context.Context) (*actions.ActionResult, e
return nil, err
}

// get clickable link for a repo path
clickableUrl := func(text string) string {
url, err := templates.Absolute(text)
if err != nil {
log.Printf("error: getting absolute url from template: %v", err)
return text
}
return output.WithHyperlink(url, text)
}

if tl.formatter.Kind() == output.TableFormat {
columns := []output.Column{
{
Heading: "Repository Path",
ValueTemplate: "{{.RepositoryPath}}",
Heading: "Name",
ValueTemplate: "{{.Name}}",
},
{
Heading: "Source",
ValueTemplate: "{{.Source}}",
},
{
Heading: "Name",
ValueTemplate: "{{.Name}}",
Heading: "Repository Path",
ValueTemplate: "{{.RepositoryPath}}",
Transformer: clickableUrl,
},
}

Expand Down