| 67 | } |
| 68 | |
| 69 | func NewCmdCreate(f *cmdutil.Factory, runF func(*CreateOptions) error) *cobra.Command { |
| 70 | opts := &CreateOptions{ |
| 71 | IO: f.IOStreams, |
| 72 | HttpClient: f.HttpClient, |
| 73 | GitClient: f.GitClient, |
| 74 | Config: f.Config, |
| 75 | Prompter: f.Prompter, |
| 76 | } |
| 77 | |
| 78 | var enableIssues bool |
| 79 | var enableWiki bool |
| 80 | |
| 81 | cmd := &cobra.Command{ |
| 82 | Use: "create [<name>]", |
| 83 | Short: "Create a new repository", |
| 84 | Long: heredoc.Docf(` |
| 85 | Create a new GitHub repository. |
| 86 | |
| 87 | To create a repository interactively, use %[1]sgh repo create%[1]s with no arguments. |
| 88 | |
| 89 | To create a remote repository non-interactively, supply the repository name and one of %[1]s--public%[1]s, %[1]s--private%[1]s, or %[1]s--internal%[1]s. |
| 90 | Pass %[1]s--clone%[1]s to clone the new repository locally. |
| 91 | |
| 92 | If the %[1]sOWNER/%[1]s portion of the %[1]sOWNER/REPO%[1]s name argument is omitted, it |
| 93 | defaults to the name of the authenticating user. |
| 94 | |
| 95 | To create a remote repository from an existing local repository, specify the source directory with %[1]s--source%[1]s. |
| 96 | By default, the remote repository name will be the name of the source directory. |
| 97 | |
| 98 | Pass %[1]s--push%[1]s to push any local commits to the new repository. If the repo is bare, this will mirror all refs. |
| 99 | |
| 100 | For language or platform .gitignore templates to use with %[1]s--gitignore%[1]s, <https://github.com/github/gitignore>. |
| 101 | |
| 102 | For license keywords to use with %[1]s--license%[1]s, run %[1]sgh repo license list%[1]s or visit <https://choosealicense.com>. |
| 103 | |
| 104 | The repo is created with the configured repository default branch, see <https://docs.github.com/en/account-and-profile/setting-up-and-managing-your-personal-account-on-github/managing-user-account-settings/managing-the-default-branch-name-for-your-repositories>. |
| 105 | `, "`"), |
| 106 | Example: heredoc.Doc(` |
| 107 | # Create a repository interactively |
| 108 | $ gh repo create |
| 109 | |
| 110 | # Create a new remote repository and clone it locally |
| 111 | $ gh repo create my-project --public --clone |
| 112 | |
| 113 | # Create a new remote repository in a different organization |
| 114 | $ gh repo create my-org/my-project --public |
| 115 | |
| 116 | # Create a remote repository from the current directory |
| 117 | $ gh repo create my-project --private --source=. --remote=upstream |
| 118 | `), |
| 119 | Args: cobra.MaximumNArgs(1), |
| 120 | Aliases: []string{"new"}, |
| 121 | RunE: func(cmd *cobra.Command, args []string) error { |
| 122 | if len(args) > 0 { |
| 123 | opts.Name = args[0] |
| 124 | } |
| 125 | |
| 126 | if len(args) == 0 && cmd.Flags().NFlag() == 0 { |