From d22286a8e8a5f3d0ddb80fd8473815c652b034a0 Mon Sep 17 00:00:00 2001 From: Sam Coe Date: Thu, 19 Aug 2021 15:58:01 -0700 Subject: [PATCH] Add examples to template --- pkg/cmd/extension/manager.go | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/pkg/cmd/extension/manager.go b/pkg/cmd/extension/manager.go index 82717aa95..f71e2d136 100644 --- a/pkg/cmd/extension/manager.go +++ b/pkg/cmd/extension/manager.go @@ -269,8 +269,40 @@ func (m *Manager) Create(name string) error { fileTmpl := heredoc.Docf(` #!/bin/bash + set -e echo "Hello %[1]s" - `, name) + + # Examples to help get started: + + # Determine if an executable is in the PATH + # if [ "$(which go)" = "" ]; then + # echo "go not found in PATH" + # exit 1 + # fi + + # Pass arguments through to a new process + # exec gh issue list "$@" -R cli/cli + + # Using the gh api command to retrieve and format information + # QUERY=' + # query($endCursor: String) { + # viewer { + # repositories(first: 100, after: $endCursor) { + # nodes { + # nameWithOwner + # stargazerCount + # } + # } + # } + # } + # ' + # TEMPLATE=' + # {{- range $repo := .data.viewer.repositories.nodes -}} + # {{- printf "name: %[2]s - stargazers: %[3]s\n" $repo.nameWithOwner $repo.stargazerCount -}} + # {{- end -}} + # ' + # exec gh api graphql --template="${TEMPLATE}" --paginate -f query="${QUERY}" + `, name, "%s", "%v") filePath := filepath.Join(name, name) err = ioutil.WriteFile(filePath, []byte(fileTmpl), 0755) return err