Skip to content

add "replace" from sprig to go template functions #11572

@armindarvish

Description

@armindarvish

Describe the feature or problem you’d like to solve

I am trying to use the "--template" formatting with gh search issues, and I want to remove newlines from the title of the issues. I tried using {{.title | replace \"\n\" " "}}:

gh search issues --sort updated --include-prs --author @me --json isPullRequest,repository,title,number,labels,updatedAt,state,url,commentsCount --template "{{range .}}{{.isPullRequest}}      {{.repository.nameWithOwner}}      {{.title | replace \"\n\" \" \"}}      {{.number}}      {{.state}}      {{.updatedAt}}      {{.labels}}      {{.url}} \n\n {{end}}" --state open

I get an error saying:

the function "replace" is not defined

There is a replace function available in the "sprig library", but it appears that this is not available in gh.

Proposed solution

Add the replace function from sprig library for go template formatting.

Sub-issues

Metadata

Metadata

Assignees

Labels

enhancementa request to improve CLIhelp wantedContributions welcome

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions