Repository: cli/cli
File: pkg/cmd/project/unlink/unlink.go (Go)

Code before:

type unlinkOpts struct {
	number       int32
	host         string
	owner        string
	repo         string
	team         string
	projectID    string
	projectTitle string
	repoID       string
	teamID       string
}

type unlinkConfig struct {
	httpClient func() (*http.Client, error)
	config     func() (gh.Config, error)
	client     *queries.Client
	opts       unlinkOpts
	io         *iostreams.IOStreams
}

func NewCmdUnlink(f *cmdutil.Factory, runF func(config unlinkConfig) error) *cobra.Command {
	opts := unlinkOpts{}
	linkCmd := &cobra.Command{
		Short: "Unlink a project from a repository or a team",
		Use:   "unlink [<number>] [flag]",
		Example: heredoc.Doc(`
			# Unlink monalisa's project 1 from her repository "my_repo"
			$ gh project unlink 1 --owner monalisa --repo my_repo

			# Unlink monalisa's organization's project 1 from her team "my_team"
			$ gh project unlink 1 --owner my_organization --team my_team

			# Unlink monalisa's project 1 from the repository of current directory if neither --repo nor --team is specified
			$ gh project unlink 1
		`),
		RunE: func(cmd *cobra.Command, args []string) error {
			client, err := client.New(f)
			if err != nil {
				return err
			}

			if len(args) == 1 {
				num, err := strconv.ParseInt(args[0], 10, 32)
				if err != nil {
					return cmdutil.FlagErrorf("invalid number: %v", args[0])
				}
				opts.number = int32(num)
			}

			if opts.repo == "" && opts.team == "" {

Review comment (suggestion):
Let's fix this like `gh project link` as it causes double flag text:

```suggestion
		Use:   "unlink [<number>]",
```

```shell
andyfeller@Andys-MBP:cli/cli ‹10449-inconsistent-examples-format›$ gh reference | grep "^### gh project"
### gh project close [<number>] [flags]
### gh project copy [<number>] [flags]
### gh project create [flags]
### gh project delete [<number>] [flags]
### gh project edit [<number>] [flags]
### gh project field-create [<number>] [flags]
### gh project field-delete [flags]
### gh project field-list number [flags]
### gh project item-add [<number>] [flags]
### gh project item-archive [<number>] [flags]
### gh project item-create [<number>] [flags]
### gh project item-delete [<number>] [flags]
### gh project item-edit [flags]
### gh project item-list [<number>] [flags]
### gh project link [<number>] [flag] [flags]
### gh project list [flags]
### gh project mark-template [<number>] [flags]
### gh project unlink [<number>] [flag] [flags]
### gh project view [<number>] [flags]


andyfeller@Andys-MBP:cli/cli ‹10449-inconsistent-examples-format›$ bin/gh reference | grep "^### gh project"
### gh project close [<number>] [flags]
### gh project copy [<number>] [flags]
### gh project create [flags]
### gh project delete [<number>] [flags]
### gh project edit [<number>] [flags]
### gh project field-create [<number>] [flags]
### gh project field-delete [flags]
### gh project field-list [<number>] [flags]
### gh project item-add [<number>] [flags]
### gh project item-archive [<number>] [flags]
### gh project item-create [<number>] [flags]
### gh project item-delete [<number>] [flags]
### gh project item-edit [flags]
### gh project item-list [<number>] [flags]
### gh project link [<number>] [flags]
### gh project list [flags]
### gh project mark-template [<number>] [flags]
### gh project unlink [<number>] [flag] [flags]
### gh project view [<number>] [flags]
```

Code after:

type unlinkOpts struct {
	number       int32
	host         string
	owner        string
	repo         string
	team         string
	projectID    string
	projectTitle string
	repoID       string
	teamID       string
}

type unlinkConfig struct {
	httpClient func() (*http.Client, error)
	config     func() (gh.Config, error)
	client     *queries.Client
	opts       unlinkOpts
	io         *iostreams.IOStreams
}

func NewCmdUnlink(f *cmdutil.Factory, runF func(config unlinkConfig) error) *cobra.Command {
	opts := unlinkOpts{}
	linkCmd := &cobra.Command{
		Short: "Unlink a project from a repository or a team",
		Use:   "unlink [<number>]",
		Example: heredoc.Doc(`
			# Unlink monalisa's project 1 from her repository "my_repo"
			$ gh project unlink 1 --owner monalisa --repo my_repo

			# Unlink monalisa's organization's project 1 from her team "my_team"
			$ gh project unlink 1 --owner my_organization --team my_team

			# Unlink monalisa's project 1 from the repository of current directory if neither --repo nor --team is specified
			$ gh project unlink 1
		`),
		RunE: func(cmd *cobra.Command, args []string) error {
			client, err := client.New(f)
			if err != nil {
				return err
			}

			if len(args) == 1 {
				num, err := strconv.ParseInt(args[0], 10, 32)
				if err != nil {
					return cmdutil.FlagErrorf("invalid number: %v", args[0])
				}
				opts.number = int32(num)
			}

			if opts.repo == "" && opts.team == "" {