Repository: cli/cli
File: command/repo.go (Go)

Code before:
	repoForkCmd.Flags().Lookup("clone").NoOptDefVal = "true"
	repoForkCmd.Flags().Lookup("remote").NoOptDefVal = "true"

	repoCmd.AddCommand(repoViewCmd)
	repoViewCmd.Flags().BoolP("web", "w", false, "Open repository in browser")
}

var repoCmd = &cobra.Command{
	Use:   "repo",
	Short: "Create, clone, fork, and view repositories",
	Long: `Work with GitHub repositories.

A repository can be supplied as an argument in any of the following formats:
- "OWNER/REPO"
- by URL, e.g. "https://github.com/OWNER/REPO"`,
}

var repoCloneCmd = &cobra.Command{
	Use:   "clone <repo> [<directory>]",
	Args:  cobra.MinimumNArgs(1),
	Short: "Clone a repository locally",
	Long: `Clone a GitHub repository locally.

To pass 'git clone' options, separate them with '--'.

In order to clone to a specific directory, provide it before the '--' instead of after the other additional options.`,
	RunE: repoClone,
}

var repoCreateCmd = &cobra.Command{
	Use:   "create [<name>]",
	Short: "Create a new repository",
	Long: `Create a new GitHub repository.

Use the "ORG/NAME" syntax to create a repository within your organization.`,
	RunE: repoCreate,
}

var repoForkCmd = &cobra.Command{
	Use:   "fork [<repository>]",
	Short: "Create a fork of a repository",
	Long: `Create a fork of a repository.

With no argument, creates a fork of the current repository. Otherwise, forks the specified repository.`,
	RunE: repoFork,
}

var repoViewCmd = &cobra.Command{
	Use:   "view [<repository>]",
	Short: "View a repository in the browser",
	Long: `View a GitHub repository.

Review comment (suggestion):
Hmm let's avoid adding this. It's technically true, but it makes help text harder to grok, and it should be obvious from the usage synopsis that `<directory>` should come before the `--`.

Code after:
	repoForkCmd.Flags().Lookup("clone").NoOptDefVal = "true"
	repoForkCmd.Flags().Lookup("remote").NoOptDefVal = "true"

	repoCmd.AddCommand(repoViewCmd)
	repoViewCmd.Flags().BoolP("web", "w", false, "Open repository in browser")
}

var repoCmd = &cobra.Command{
	Use:   "repo",
	Short: "Create, clone, fork, and view repositories",
	Long: `Work with GitHub repositories.

A repository can be supplied as an argument in any of the following formats:
- "OWNER/REPO"
- by URL, e.g. "https://github.com/OWNER/REPO"`,
}

var repoCloneCmd = &cobra.Command{
	Use:   "clone <repo> [<directory>]",
	Args:  cobra.MinimumNArgs(1),
	Short: "Clone a repository locally",
	Long: `Clone a GitHub repository locally.

To pass 'git clone' flags, separate them with '--'.`,
	RunE: repoClone,
}

var repoCreateCmd = &cobra.Command{
	Use:   "create [<name>]",
	Short: "Create a new repository",
	Long: `Create a new GitHub repository.

Use the "ORG/NAME" syntax to create a repository within your organization.`,
	RunE: repoCreate,
}

var repoForkCmd = &cobra.Command{
	Use:   "fork [<repository>]",
	Short: "Create a fork of a repository",
	Long: `Create a fork of a repository.

With no argument, creates a fork of the current repository. Otherwise, forks the specified repository.`,
	RunE: repoFork,
}

var repoViewCmd = &cobra.Command{
	Use:   "view [<repository>]",
	Short: "View a repository in the browser",
	Long: `View a GitHub repository.

With no argument, the repository for the current directory is displayed.`,