Repository: cli/cli
Pull request #7923 (2023-08-31 21:40:37)

rename template to mark-template cmd
Follow up to https://github.com/cli/cli/pull/7916 it was decided that `mark-template` is a better name for that command. As this hasn't been included in a release yet, it's safe to update.

Command output
```
go run cmd/gh/main.go project -h

Work with GitHub Projects. Note that the token you are using must have 'project' scope, which is not set by default. You can verify your token scope by running 'gh auth status' and add the project scope by running 'gh auth refresh -s project'.

USAGE
  gh project <command> [flags]

AVAILABLE COMMANDS
  ...
  mark-template: Mark a project as a template
```

Tested:
```
go run cmd/gh/main.go project mark-template 1 --owner "github"
go run cmd/gh/main.go project mark-template 1 --owner "github" --undo
```

Note: this does not change the JSON field name, which remains `template` to match the returned API value.

cliAutomation: Hi! Thanks for the pull request. Please ensure that this change is linked to an issue by mentioning an issue number in the description of the pull request. If this pull request would close the issue, please put the word 'Fixes' before the issue number somewhere in the pull request body. If this is a tiny change like fixing a typo, feel free to ignore this message.

Patch:
diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml
index b15b23806..1f1a24b1d 100644
--- a/.github/workflows/deployment.yml
+++ b/.github/workflows/deployment.yml
@@ -340,6 +340,7 @@ jobs:
         if: inputs.environment == 'production' && !contains(inputs.tag_name, '-')
         with:
           formula-name: gh
+          formula-path: Formula/g/gh.rb
           tag-name: ${{ inputs.tag_name }}
           push-to: cli/homebrew-core
         env:
diff --git a/pkg/cmd/project/template/template.go b/pkg/cmd/project/mark-template/mark_template.go
similarity index 75%
rename from pkg/cmd/project/template/template.go
rename to pkg/cmd/project/mark-template/mark_template.go
index 9ef0732b9..92eb87ca6 100644
--- a/pkg/cmd/project/template/template.go
+++ b/pkg/cmd/project/mark-template/mark_template.go
@@ -1,4 +1,4 @@
-package template
+package marktemplate
 
 import (
 	"fmt"
@@ -14,7 +14,7 @@ import (
 	"github.com/spf13/cobra"
 )
 
-type templateOpts struct {
+type markTemplateOpts struct {
 	owner     string
 	undo      bool
 	number    int32
@@ -22,9 +22,9 @@ type templateOpts struct {
 	format    string
 }
 
-type templateConfig struct {
+type markTemplateConfig struct {
 	client *queries.Client
-	opts   templateOpts
+	opts   markTemplateOpts
 	io     *iostreams.IOStreams
 }
 
@@ -39,17 +39,17 @@ type unmarkProjectTemplateMutation struct {
 	} `graphql:"unmarkProjectV2AsTemplate(input:$input)"`
 }
 
-func NewCmdTemplate(f *cmdutil.Factory, runF func(config templateConfig) error) *cobra.Command {
-	opts := templateOpts{}
-	templateCmd := &cobra.Command{
+func NewCmdMarkTemplate(f *cmdutil.Factory, runF func(config markTemplateConfig) error) *cobra.Command {
+	opts := markTemplateOpts{}
+	markTemplateCmd := &cobra.Command{
 		Short: "Mark a project as a template",
-		Use:   "template [<number>]",
+		Use:   "mark-template [<number>]",
 		Example: heredoc.Doc(`
 			# mark the github org's project "1" as a template
-			gh project template 1 --owner "github"
+			gh project mark-template 1 --owner "github"
 
 			# unmark the github org's project "1" as a template
-			gh project template 1 --owner "github" --undo
+			gh project mark-template 1 --owner "github" --undo
 		`),
 		Args: cobra.MaximumNArgs(1),
 		RunE: func(cmd *cobra.Command, args []string) error {
@@ -66,7 +66,7 @@ func NewCmdTemplate(f *cmdutil.Factory, runF func(config templateConfig) error)
 				opts.number = int32(num)
 			}
 
-			config := templateConfig{
+			config := markTemplateConfig{
 				client: client,
 				opts:   opts,
 				io:     f.IOStreams,
@@ -76,18 +76,18 @@ func NewCmdTemplate(f *cmdutil.Factory, runF func(config templateConfig) error)
 			if runF != nil {
 				return runF(config)
 			}
-			return runTemplate(config)
+			return runMarkTemplate(config)
 		},
 	}
 
-	templateCmd.Flags().StringVar(&opts.owner, "owner", "", "Login of the org owner.")
-	templateCmd.Flags().BoolVar(&opts.undo, "undo", false, "Unmark the project as a template.")
-	cmdutil.StringEnumFlag(templateCmd, &opts.format, "format", "", "", []string{"json"}, "Output format")
+	markTemplateCmd.Flags().StringVar(&opts.owner, "owner", "", "Login of the org owner.")
+	markTemplateCmd.Flags().BoolVar(&opts.undo, "undo", false, "Unmark the project as a template.")
+	cmdutil.StringEnumFlag(markTemplateCmd, &opts.format, "format", "", "", []string{"json"}, "Output format")
 
-	return templateCmd
+	return markTemplateCmd
 }
 
-func runTemplate(config templateConfig) error {
+func runMarkTemplate(config markTemplateConfig) error {
 	canPrompt := config.io.CanPrompt()
 	owner, err := config.client.NewOwner(canPrompt, config.opts.owner)
 	if err != nil {
@@ -127,7 +127,7 @@ func runTemplate(config templateConfig) error {
 	return printResults(config, query.TemplateProject.Project)
 }
 
-func markTemplateArgs(config templateConfig) (*markProjectTemplateMutation, map[string]interface{}) {
+func markTemplateArgs(config markTemplateConfig) (*markProjectTemplateMutation, map[string]interface{}) {
 	return &markProjectTemplateMutation{}, map[string]interface{}{
 		"input": githubv4.MarkProjectV2AsTemplateInput{
 			ProjectID: githubv4.ID(config.opts.projectID),
@@ -139,7 +139,7 @@ func markTemplateArgs(config templateConfig) (*markProjectTemplateMutation, map[
 	}
 }
 
-func unmarkTemplateArgs(config templateConfig) (*unmarkProjectTemplateMutation, map[string]interface{}) {
+func unmarkTemplateArgs(config markTemplateConfig) (*unmarkProjectTemplateMutation, map[string]interface{}) {
 	return &unmarkProjectTemplateMutation{}, map[string]interface{}{
 		"input": githubv4.UnmarkProjectV2AsTemplateInput{
 			ProjectID: githubv4.ID(config.opts.projectID),
@@ -151,7 +151,7 @@ func unmarkTemplateArgs(config templateConfig) (*unmarkProjectTemplateMutation,
 	}
 }
 
-func printResults(config templateConfig, project queries.Project) error {
+func printResults(config markTemplateConfig, project queries.Project) error {
 	if !config.io.IsStdoutTTY() {
 		return nil
 	}
@@ -165,7 +165,7 @@ func printResults(config templateConfig, project queries.Project) error {
 	return err
 }
 
-func printJSON(config templateConfig, project queries.Project) error {
+func printJSON(config markTemplateConfig, project queries.Project) error {
 	b, err := format.JSONProject(project)
 	if err != nil {
 		return err
diff --git a/pkg/cmd/project/project.go b/pkg/cmd/project/project.go
index d9858953d..cb5e54149 100644
--- a/pkg/cmd/project/project.go
+++ b/pkg/cmd/project/project.go
@@ -17,7 +17,7 @@ import (
 	cmdItemEdit "github.com/cli/cli/v2/pkg/cmd/project/item-edit"
 	cmdItemList "github.com/cli/cli/v2/pkg/cmd/project/item-list"
 	cmdList "github.com/cli/cli/v2/pkg/cmd/project/list"
-	cmdTemplate "github.com/cli/cli/v2/pkg/cmd/project/template"
+	cmdTemplate "github.com/cli/cli/v2/pkg/cmd/project/mark-template"
 	cmdView "github.com/cli/cli/v2/pkg/cmd/project/view"
 	"github.com/cli/cli/v2/pkg/cmdutil"
 	"github.com/spf13/cobra"
@@ -44,7 +44,7 @@ func NewCmdProject(f *cmdutil.Factory) *cobra.Command {
 	cmd.AddCommand(cmdDelete.NewCmdDelete(f, nil))
 	cmd.AddCommand(cmdEdit.NewCmdEdit(f, nil))
 	cmd.AddCommand(cmdView.NewCmdView(f, nil))
-	cmd.AddCommand(cmdTemplate.NewCmdTemplate(f, nil))
+	cmd.AddCommand(cmdTemplate.NewCmdMarkTemplate(f, nil))
 
 	// items
 	cmd.AddCommand(cmdItemList.NewCmdList(f, nil))


Test patch:
diff --git a/pkg/cmd/project/template/template_test.go b/pkg/cmd/project/mark-template/mark_template_test.go
similarity index 91%
rename from pkg/cmd/project/template/template_test.go
rename to pkg/cmd/project/mark-template/mark_template_test.go
index df42ae5ca..581c4d8f6 100644
--- a/pkg/cmd/project/template/template_test.go
+++ b/pkg/cmd/project/mark-template/mark_template_test.go
@@ -1,4 +1,4 @@
-package template
+package marktemplate
 
 import (
 	"testing"
@@ -11,11 +11,11 @@ import (
 	"gopkg.in/h2non/gock.v1"
 )
 
-func TestNewCmdTemplate(t *testing.T) {
+func TestNewCmdMarkTemplate(t *testing.T) {
 	tests := []struct {
 		name        string
 		cli         string
-		wants       templateOpts
+		wants       markTemplateOpts
 		wantsErr    bool
 		wantsErrMsg string
 	}{
@@ -28,21 +28,21 @@ func TestNewCmdTemplate(t *testing.T) {
 		{
 			name: "number",
 			cli:  "123",
-			wants: templateOpts{
+			wants: markTemplateOpts{
 				number: 123,
 			},
 		},
 		{
 			name: "owner",
 			cli:  "--owner monalisa",
-			wants: templateOpts{
+			wants: markTemplateOpts{
 				owner: "monalisa",
 			},
 		},
 		{
 			name: "undo",
 			cli:  "--undo",
-			wants: templateOpts{
+			wants: markTemplateOpts{
 				undo: true,
 			},
 		},
@@ -50,7 +50,7 @@ func TestNewCmdTemplate(t *testing.T) {
 		{
 			name: "json",
 			cli:  "--format json",
-			wants: templateOpts{
+			wants: markTemplateOpts{
 				format: "json",
 			},
 		},
@@ -68,8 +68,8 @@ func TestNewCmdTemplate(t *testing.T) {
 			argv, err := shlex.Split(tt.cli)
 			assert.NoError(t, err)
 
-			var gotOpts templateOpts
-			cmd := NewCmdTemplate(f, func(config templateConfig) error {
+			var gotOpts markTemplateOpts
+			cmd := NewCmdMarkTemplate(f, func(config markTemplateConfig) error {
 				gotOpts = config.opts
 				return nil
 			})
@@ -164,8 +164,8 @@ func TestRunMarkTemplate_Org(t *testing.T) {
 
 	ios, _, stdout, _ := iostreams.Test()
 	ios.SetStdoutTTY(true)
-	config := templateConfig{
-		opts: templateOpts{
+	config := markTemplateConfig{
+		opts: markTemplateOpts{
 			owner:  "github",
 			number: 1,
 		},
@@ -173,7 +173,7 @@ func TestRunMarkTemplate_Org(t *testing.T) {
 		io:     ios,
 	}
 
-	err := runTemplate(config)
+	err := runMarkTemplate(config)
 	assert.NoError(t, err)
 	assert.Equal(
 		t,
@@ -256,8 +256,8 @@ func TestRunUnmarkTemplate_Org(t *testing.T) {
 
 	ios, _, stdout, _ := iostreams.Test()
 	ios.SetStdoutTTY(true)
-	config := templateConfig{
-		opts: templateOpts{
+	config := markTemplateConfig{
+		opts: markTemplateOpts{
 			owner:  "github",
 			number: 1,
 			undo:   true,
@@ -266,7 +266,7 @@ func TestRunUnmarkTemplate_Org(t *testing.T) {
 		io:     ios,
 	}
 
-	err := runTemplate(config)
+	err := runMarkTemplate(config)
 	assert.NoError(t, err)
 	assert.Equal(
 		t,