Skip to content

Commit

Permalink
Feature Clickable Template Links in Terminal azd template list (#2845)
Browse files Browse the repository at this point in the history
* Implement clickable links
  • Loading branch information
john0isaac committed Oct 11, 2023
1 parent c711920 commit f38a157
Showing 1 changed file with 16 additions and 4 deletions.
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

0 comments on commit f38a157

Please sign in to comment.